I am using codeigniter. I want to bind the column of my table with dropdownlistbox.
// 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);
This is practically the easiest way to do this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.