Welcome Guest, Not a member yet? Register   Sign In
need help

i am new to codeigniter
i have done fatch data form database ssuccefully
but how i delete row respective to id
plz help me

in core coading i am doing...
<a href="selection.php?todo=&lt;?=$row['id']?&gt;">Delete</a>

and at the top of the program
$id = $_REQUEST['todo'];
mysql_query("delete from formtable where id = '".$_GET['REQUEST']."' ");

but how it done in codeigniter
plz help me

Quote:in core coading i am doing…

For Delete in CI,


Generates a delete SQL string and runs the query.
$this->db->delete('mytable', array('id' => $id));

// Produces:
// DELETE FROM mytable
// WHERE id = $id

The first parameter is the table name, the second is the where clause. You can also use the where() or or_where() functions instead of passing the data to the second parameter of the function:

$this->db->where('id', $id);

// Produces:
// DELETE FROM mytable
// WHERE id = $id

An array of table names can be passed into delete() if you would like to delete data from more than 1 table.

$tables = array('table1', 'table2', 'table3');
$this->db->where('id', '5');

Please follow this url

and at the top of the program
$id = $_REQUEST[‘todo’];
mysql_query(“delete from formtable where id = ‘“.$_GET[‘REQUEST’].”’ “);

but how it done in codeigniter
plz help me

sir plz give me complete example
what i write in view,controller and model

plz sir
what i write in view
my table name is pankajdb
having 5 element

thanks in advanced


dixcoder has shown you above how to delete an id using CodeIgniter's Active Record.

You need to read the CodeIgniter user guide here



As far as your view, you need to read the CodeIgniter form_helper here:

Form Helper

Then read the CodeIgniter Form Validation here:

Form Validation

No one is going to write the whole code for you, you need to start reading the CodeIgniter user guide and try to do a lot of these things on your own!

If you have a specific problem then I am sure that lots of users on here will help you out but to code the whole thing for you I doubt it.


Also any destructive data manipulation should be done from a POST, not a GET...

Theme © iAndrew 2016 - Forum software by © MyBB