[eluser]hvalente13[/eluser]
Hi,
That's how I do it:
Model
Code:
function get_list(){
$this->db->select('*')->from('table');
$query = $this->db->get();
if($query->num_rows()>0){
$opts[''] = 'Select an option';
foreach($query->result() as $row){
$opts[$row->id] = $row->name;
}
}
return $opts;
}
Controler
Code:
// with this option you can compare with the db data, and i will select the right option when page loads
// model function to retrieve db data
$data['name'] = $row->name;
$data['dd_data'] = $this->model_name->get_list();
View
Code:
<?php echo form_dropdown('name',$dd_data,$name); ?>
EDIT:
You can pass parameters by:
Code:
<?php echo form_dropdown(array('name'=>$scalecontent['name'],'id'=>$scalecontent['id']),$dd_data,$name); ?>
Guess I didn't forget anything. I was trying to make it generic...
Hope this helps
Hvalente13