![]() |
How to (correcly) pass variables from a loop (in view) to a Controller - 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: How to (correcly) pass variables from a loop (in view) to a Controller (/showthread.php?tid=39685) |
How to (correcly) pass variables from a loop (in view) to a Controller - El Forum - 03-17-2011 [eluser]Juan Velandia[/eluser] Hello everyone, im trying to create a page in wich people could post some comments or questions of a certain record from a data base, (similar to facebook). The issue is that I'm trying to pass the id of a particular database record, but I end up passing the higest (last) id of the loop Here it is: model: Code: function get_tarea() view Code: foreach ($tarea as $row): controller (for the insertion) Code: function question_insert(){ The issue is that post('id_tarea') is always the same: the last record from the database. If anyone wants to see the actual output of this code: http://www.nemoestudio.com/es/support Thanks in advance for your ideas! How to (correcly) pass variables from a loop (in view) to a Controller - El Forum - 03-17-2011 [eluser]bluematt[/eluser] You need an echo on your form_close(). Your browser is treating this as one big form, and where multiple inputs have the same name, the last one POSTed will be used as the value. How to (correcly) pass variables from a loop (in view) to a Controller - El Forum - 03-18-2011 [eluser]Juan Velandia[/eluser] Hello bluematt... thanks a lot! sometimes my background as a ghraphic designer doesn´t help to solve this kind ok issues. best regards! |