我正在使用codeigniter.
我想用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);
实际上,这是最简单的方法.