[eluser]Xeroxeen[/eluser]
[quote author="JoostV" date="1373866307"]Make sure the array you are feeding to the dropdown is a key => value pair array.
Code:
$options = array(
'' => 'Pick a color',
'white' => 'White',
'purple' => 'Purple',
'yellow' => 'Yellow',
);
echo form_dropdown('shirts', $options);
[/quote]
thanks for your comment.this is my model,controller and view parts
model
Code:
function getDBdata()
{
$dataGet="SELECT Name FROM `data`";
$dataGetQuery=$this->db->query($dataGet);
$result=$dataGetQuery->result_array();
foreach ($result as $values){
$elements[]=$values;
}
return $elements;
}
controller
Code:
$elements=$this->dataModel->getDBdata();
$data['datagot']=$elements;
$this->load->view('user',$data);
view
Code:
<div class="LeftSide"><?php echo 'Category';?></div>
<div class="RightSide"><?php echo form_dropdown('selectedvalue', $datagot, 'Datadropdown');?></div>
Data in dropdown shows well.but it shows with array index number.
Ex:-
0 data1
1 data1
2 data3 like that.I want only data1,data2,data3.Hope u can help me