![]() |
how to fetch data from database automatically on first load - 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 fetch data from database automatically on first load (/showthread.php?tid=22115) |
how to fetch data from database automatically on first load - El Forum - 08-30-2009 [eluser]ranjitbd[/eluser] i can retrieve data from database when any event triggers like click on button or a link. but in my index page a search criteria box is there where 4 combo box is exist for user search option. i have to fetch data from database when the page is loaded. earlier i have done this with flat php. the code is showing below: //city selection box Code: <select name="city" id="city"> but now what to do with CI how to fetch data from database automatically on first load - El Forum - 08-30-2009 [eluser]alboyd[/eluser] I could help you but it seems you don't even acknowledge where you have been helped. EG That other thread where you seem more interested in having some stupid argument about using code blocks. how to fetch data from database automatically on first load - El Forum - 08-30-2009 [eluser]ranjitbd[/eluser] i told you sir that i am new to CI and i dnt knw english well so plz help me. thanks in advance. how to fetch data from database automatically on first load - El Forum - 08-30-2009 [eluser]alboyd[/eluser] In your controller you need to make a call to your model to retrieve the selection values - recommend grab an ID and a display value. In your controller you should save that query result to a variable to pass into the view. In your view you should iterate through the query results and do as you have already done and create the html for your select dropdown. EDIT: Once your query results are in an array available to your view it could look something like this: Code: <select name="city" id="city"> |