![]() |
select box, mySQL, form_validation and form_helper - 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: select box, mySQL, form_validation and form_helper (/showthread.php?tid=21701) |
select box, mySQL, form_validation and form_helper - El Forum - 08-18-2009 [eluser]Neeraj Kumar[/eluser] Hi all! I have a huge list of years, from 1900 - 2009. Now following is my problem I need to store data into MySQl DB, this is what I do in view, when a user registers at site for the first time: Code: <select name="year" id="year"> I can run form_validation etc. perfectly. The problem arises when I want a user to edit this field again. For that I present him another view viz. 'edit_view'. Now what and how should I create this drop down dynamically and present him all the fields with the one stored in the database as selected. I tried to use form_dropdown(), but where am supposed to specify the set_select() so that when form is submitted and processed, user can see last selected value just like he saw in registration form select box, mySQL, form_validation and form_helper - El Forum - 08-18-2009 [eluser]Neeraj Kumar[/eluser] come on, somebody? I need a solution to this problem... please select box, mySQL, form_validation and form_helper - El Forum - 08-18-2009 [eluser]spheroid[/eluser] Assuming in your controller you pass the selected year to $data['year'], and add all the values of the years into an array, such as $year_array, you could do this: Code: $year_array = array(); |