[eluser]davidbehler[/eluser]
I usually do something like this:
Controller:
Code:
$data['city_list'] = $this->City_model->get_dropdown_list();
$this->load->view('my_view_file', $data);
Model:
Code:
function get_dropdown_list()
{
$this->db->from('city');
$this->db->order_by('name');
$result = $this->db->get();
$return = array();
if($result->num_rows() > 0) {
foreach($result->result_array() as $row) {
$return[$row['id']] = $row['name'];
}
}
return $return;
}
View:
Code:
<?php echo form_dropdown('city_id', $city_list, set_value('city_id', $city_id));
Totally untested and especially the get_dropdown_list function can be improved a lot, but I think you get what I'm doing here.