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

[eluser]Mutsop[/eluser]
Hi,

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

controller:
Code:
$this->data['dropdown'] = array(
   $this->my_model->get_values(),
);

And this is my view:
Code:
<?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.


Messages In This Thread
array to dropdown values - by El Forum - 01-11-2011, 03:16 AM
array to dropdown values - by El Forum - 01-11-2011, 03:28 AM
array to dropdown values - by El Forum - 01-11-2011, 03:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB