![]() |
populating form from database - 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: populating form from database (/showthread.php?tid=14214) |
populating form from database - El Forum - 12-23-2008 [eluser]sore eyes[/eluser] hi, I'm new to codeigniter and not much older with php, so please excuse. I want to populate a form from a database. First by listing shops, then selecting one from the list to populate the form. The controller is 'welcome': Code: <?php Code: The model is 'MShops': The views are 'template': Code: <?php foreach ($query->result() as $row):?> And view 'shop_view': Code: <h1><?=$title?></h1> I don't know what to use for "value" for the last piece of code. populating form from database - El Forum - 12-23-2008 [eluser]jalalski[/eluser] '$query->shop_id' and '$query->shopname' ? BTW, I don't see where you are loading the Model in the Controller. populating form from database - El Forum - 12-23-2008 [eluser]sore eyes[/eluser] thanks for responding jalalski, ’$query->shop_id’ results in an error Quote:Message: Undefined property: CI_DB_mysql_result::$shop_id The model is autoloaded. populating form from database - El Forum - 12-23-2008 [eluser]jalalski[/eluser] OK. So, in the model, you are using: Code: $data = $this->db->get('shop'); which is returning a query result, better to do this: Code: $data = $this->db->get('shop'); although you may want to add some error handling in their as well. populating form from database - El Forum - 12-23-2008 [eluser]sore eyes[/eluser] hi jalalski, that's done the trick. Thank you so much. |