Welcome Guest, Not a member yet? Register   Sign In
problem drop -down dynamically

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(
       'small'         => 'Small Shirt',
       'med'           => 'Medium Shirt',
       'large'         => 'Large Shirt',
       'xlarge'        => 'Extra Large Shirt',

And in your view, create the dropdown list with the form_dropdown helper function:

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! ***/

Messages In This Thread
problem drop -down dynamically - by Delta-51 - 05-29-2015, 11:24 AM
RE: problem drop -down dynamically - by Athov - 05-30-2015, 05:07 AM
RE: problem drop -down dynamically - by includebeer - 05-30-2015, 11:02 AM
RE: problem drop -down dynamically - by Delta-51 - 05-31-2015, 11:51 PM

Theme © iAndrew 2016 - Forum software by © MyBB