problem drop -down dynamically |
Hello thank you for welcoming me , I just started programming in php and using Codeigniter , and I have a big problem that is in a registration form can not I add a drop -down gives me the values and names dynamically .
Values and names are in the database . In php without Codeigniter I managed to write the code ( picture attached ) but in Codeigniter not know how. Thanks in advance.
Well the easiest without model is
PHP Code: <?php PHP Code: <!-- some view -->
(05-30-2015, 05:07 AM)Athov Wrote: Well the easiest without model is Just notice in the image you are loading the database in there not sure why. I would recommend using the config/database.php and autoload the library
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
If you're new to PHP programming and CodeIgniter, you better learn to do it the right way!
Get the data from a model and return an array in the format expected by the form_dropdown function. Example of the format expected: PHP Code: $options = array( And in your view, create the dropdown list with the form_dropdown helper function: http://www.codeigniter.com/userguide3/he...m_dropdown PHP Code: echo form_dropdown('shirts', $options, 'large'); Loading data directly in the controller is bad design and bad practice. Reinventing the wheel to create a dropdown list is also bad practice. I strongly suggest you read the user guide to learn all the features availble in CodeIgniter to make your life easier.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/ PHP Code: <select name="name" > where mistake |
Welcome Guest, Not a member yet? Register Sign In |