2011-01-31 64 views

回答

3
// your controller 
function index() { 
    $result = $this->your_model->get_list(); 

    foreach ($result as $country) 
    { 
     $countries[$country->id] = $country->name; 
    } 

    $data['countries'] = $countries; 
    $this->load->view('your_view', $data); 
} 

//your model 
function get_list() { 
    return $this->db->get('countries'); 
} 

// your view 
echo form_dropdown('country', $countries); 

這實際上是最簡單的方法。