Deleting table records - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Deleting table records (/showthread.php?tid=52727) |
Deleting table records - El Forum - 06-24-2012 [eluser]ozy123[/eluser] Hi guys, Probably a dumb question but how do I pass values from a table to a controller via a delete button? So I have a table in my view which retrieves values from the database and displays: User Date delete Jack 21/05/2012 delete john 20/05/2012 And I've added a delete button like so: echo '<td align="center">' . "<a href='/codeigniter/auth/delete_avail/" . $date . "'>Delete</a>" . "</td>"; But I have no idea how to retrieve the date from the row to pass as the variable $date to the controller? Thanks for any help. Deleting table records - El Forum - 06-24-2012 [eluser]LuckyFella73[/eluser] hi ozy123, your table rows are generated via a loop I guess. Whithin that loop you have 2 possibilities. The first one is build the delete anchors like Code: <a href="<?php echo base_url();?>controller/delete/<?php echo $row->id;?>">delete</a> would make a delete function (or better in your model) using that id you get from the URI segment. The second way is to build a form in every singel row, storing the row->id in a hidden input field. All forms would point to the same controller/method where you read the id value via input->post('id') and delete the row that way. Best regards Deleting table records - El Forum - 06-25-2012 [eluser]ozy123[/eluser] oh! Of course. I'm real sorry for wasting your time. Long day yesterday brain must have just shutdown. Thanks for taking the time, appreciate it. Deleting table records - El Forum - 06-25-2012 [eluser]LuckyFella73[/eluser] You are welcome - no time wasted |