Welcome Guest, Not a member yet? Register   Sign In
Having problems with creating a CRUD..
#13

[eluser]ealonw[/eluser]
Okay here is my complete controller....

************************************************
class Contact extends Controller {

function contact()
{
parent::Controller();
$this->load->library('database');
$this->load->helper(array('form', 'url'));
$this->load->scaffolding( 'usercomment');
}


function index()
{
// Produces: SELECT * FROM mytable
$query = $this->db->get('usercomment');
//return $query;
$this->load->view('contact_view',array('query'=>$query));
}


function insert()
{
$data = array(

'fname' => $this->input->post('fname', FALSE),
'lname' => $this->input->post('lname', FALSE),
'email' => $this->input->post('email', FALSE),
'comment' => $this->input->post('comment', FALSE),
);

$this->db->insert('usercomment', $data);
/** Produces: INSERT INTO usercomment (fname, lname, email, comment)
VALUES ('First Name', 'Last Name', 'Email', 'Comment')**/
$this->load->view('insert_contact_view');
}


function update()
{
error_reporting(0);
$this->load->helper('form');
// $id = $this->uri->segment(3);
$query = $this->db->getwhere('usercomment', array('id' => $id));
$data['id'] = $query->result();

if ( count($_POST) > 0 )
{
$this->db->where('id', $id);
$this->db->update('usercomment', $_POST);
redirect('');
}
else
{
$this->load->view('update_contact_view', $data);
}
}



function delete($id = -1)
{
$this->db->delete('usercomment', array('id' => $id));

***************************************************************

Yes my database has id set to auto... But still dont see the problem... my form open seems to fail...


Messages In This Thread
Having problems with creating a CRUD.. - by El Forum - 06-05-2008, 12:03 PM
Having problems with creating a CRUD.. - by El Forum - 06-05-2008, 12:22 PM
Having problems with creating a CRUD.. - by El Forum - 06-05-2008, 05:14 PM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:26 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:34 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:38 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 11:46 AM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 12:01 PM
Having problems with creating a CRUD.. - by El Forum - 06-06-2008, 12:16 PM
Having problems with creating a CRUD.. - by El Forum - 06-07-2008, 01:58 AM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 12:45 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 01:01 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 02:22 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 02:54 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 03:22 PM
Having problems with creating a CRUD.. - by El Forum - 06-10-2008, 03:47 PM
Having problems with creating a CRUD.. - by El Forum - 06-11-2008, 04:50 PM
Having problems with creating a CRUD.. - by El Forum - 06-11-2008, 05:57 PM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 10:09 AM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 12:33 PM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 02:52 PM
Having problems with creating a CRUD.. - by El Forum - 06-12-2008, 08:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB