need help |
[eluser]pankaj.sharma[/eluser]
hiiii 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=<?=$row['id']?>">Delete</a> and at the top of the program if(isset($_REQUEST['todo'])) { $id = $_REQUEST['todo']; mysql_query("delete from formtable where id = '".$_GET['REQUEST']."' "); header("locationelect.php"); } but how it done in codeigniter plz help me
[eluser]imn.codeartist[/eluser]
Quote:in core coading i am doing… For Delete in CI, Code: $this->db->delete(); Generates a delete SQL string and runs the query. Code: $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: Code: $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. Code: $tables = array('table1', 'table2', 'table3'); Please follow this url http://ellislab.com/codeigniter/user-gui...tml#delete and at the top of the program if(isset($_REQUEST[‘todo’])) { $id = $_REQUEST[‘todo’]; mysql_query(“delete from formtable where id = ‘“.$_GET[‘REQUEST’].”’ “); header(“locationelect.php”); } but how it done in codeigniter plz help me
[eluser]pankaj.sharma[/eluser]
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 id,name,fname,city,state thanks in advanced
[eluser]InsiteFX[/eluser]
dixcoder has shown you above how to delete an id using CodeIgniter's Active Record. You need to read the CodeIgniter user guide here Database: Database 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. Enjoy InsiteFX
[eluser]n0xie[/eluser]
Also any destructive data manipulation should be done from a POST, not a GET... |
Welcome Guest, Not a member yet? Register Sign In |