Welcome Guest, Not a member yet? Register   Sign In
array to dropdown values


I'm trying to get an array (retrieved from my database) to the values of my dropdown box.
Here is what I have:

$this->data['dropdown'] = array(

And this is my view:
<?php echo form_dropdown('dropdownname', $dropdown, 'some value');?>

My print_r is:
Quote:Array ( [0] => stdClass Object ( [id] => 1 [name] => value1 [description] => value1description ) [1] => stdClass Object ( [id] => 2 [name] => value2 [description] => value2description ) )

So How do I get the valuexdescription into my dropdown? As this is an array object and should be converted.... Don't really know how Sad Also, when the form should be submitted, the [name] should be passed not the desciption.

Can't you just return the results from get_values function in this format
$options = array(
                  'small'  => 'Small Shirt',
                  'med'    => 'Medium Shirt',
                  'large'   => 'Large Shirt',
                  'xlarge' => 'Extra Large Shirt',

which will then serve as second parameter to form_dropdown ?

Well technically I can, but would like to know for futur use if possible Big Grin
As for now, it's a simple "privilege" selection box for users. So it shouldn't be dynamicly created.

Theme © iAndrew 2016 - Forum software by © MyBB