![]() |
Update some content - 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: Update some content (/showthread.php?tid=42372) |
Update some content - El Forum - 06-05-2011 [eluser]sam_weiss[/eluser] Hi people, i'm new in codeigniter and i'm very excited. But now I got stuck on a problem. I am not able to edit the content via a form. Controller: Code: class Site extends CI_Controller{ Function update in Model: Code: function update($tables){ Commentsview(View): Code: <?php echo form_open('site/update'); ?> So it gives me this error: Quote:A Database Error Occurred Someone help me? And sorry my english. Update some content - El Forum - 06-05-2011 [eluser]samitrimal[/eluser] Change in the model Code: function update($tables){ to Code: function update($tables){ Update some content - El Forum - 06-06-2011 [eluser]sam_weiss[/eluser] Hi samitrimal, I had already tried that and it did not work. When i trying edit, sometimes works but field of id is 0. Update some content - El Forum - 06-06-2011 [eluser]Twisted1919[/eluser] Where you set your "where condition" ? You update all the records from the table and set them same data(ie: id=0) so yes, it's obvious you get an error. LE: the method posted was wrong. Update some content - El Forum - 06-06-2011 [eluser]LuckyFella73[/eluser] In your edit form you need a hidden form field and set the value equal to the id of the record you are editing. When calling the update method (after submitting the form) you need a line like: Code: $tables['id'] = $this->input->post('row_id'); Otherwise your model doesn't know which row has to be updated. If you modify your script like that the update method from your model should work like you tried inbetween and samitrimal suggested: Code: function update($tables){ Update some content - El Forum - 06-06-2011 [eluser]sam_weiss[/eluser] Still don't working. :/ Update some content - El Forum - 06-06-2011 [eluser]LuckyFella73[/eluser] sorry I didn't check the model code carefully enough: Code: function update($tables){ |