![]() |
Cannot delete from database - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Cannot delete from database (/showthread.php?tid=68517) Pages:
1
2
|
RE: Cannot delete from database - michaeldtrek - 07-22-2017 (07-22-2017, 10:24 AM)[email protected] Wrote:(07-22-2017, 09:57 AM)Wouter60 Wrote: Please, define "didn't work". Thanks for you time. I got it to work, I just dropped the row and re-added it. Also your link that you sent works as well Thanks to everybody who has chimed in to help me. RE: Cannot delete from database - Paradinight - 07-22-2017 (07-22-2017, 11:11 AM)[email protected] Wrote:(07-22-2017, 10:24 AM)[email protected] Wrote:(07-22-2017, 09:57 AM)Wouter60 Wrote: Please, define "didn't work". $post['id'] <- is not the id from the database? ![]() if you need to reset the id, you do something wrong very wrong RE: Cannot delete from database - Wouter60 - 07-23-2017 Quote:I need to figure out how to reset the auto increment in the database if I can. At least I think this is the best way to proceed. No it's not. Let your controller fetch the records (optionally via a model), and pass them as an array to the view that shows the table. Use a foreach... structure to display the records. Very basic example: Code: <table> This way, each delete button refers to an existing record. RE: Cannot delete from database - michaeldtrek - 07-23-2017 (07-23-2017, 04:27 AM)Wouter60 Wrote:Quote:I need to figure out how to reset the auto increment in the database if I can. At least I think this is the best way to proceed. Thanks, Even though I fixed the issue I'm in the learning mode and I'm going to take your advice and fetch the records in the Model. For me it's a challenge as I believe it will help me learn how to structure the code better. Again thanks for your input I really appreciate it. RE: Cannot delete from database - Wouter60 - 07-24-2017 Remember to let your model return the records as an array of objects in order to use the object syntax in the view, like $post->id. Otherwise, you must use the array syntax: $post['id']. PHP Code: $query = $this->db->order_by('datetime','ASC')->get('posts'); |