//模型
function shop_dropdown()
{
$this->db->select('shop');
$this->db->from('shop');
//$this->db->where('category_online', 1);
$query = $this->db->get();
foreach($query->result_array() as $row)
{
$data[$row['id']]=$row['name'];
}
return $data;
}
控制器//
function shop_dropdown()
{
$data = array();
$this->load->model('shop_model');
$shop['select_options'] = $this->shop_model->shop_dropdown();
$this->load->view('shop/product_view', $shop);
}
看法//
<?php
echo form_dropdown('shop', $select_options);
?>
这不起作用。请帮助我从数据库中创建一个下拉列表。如果您可以编写新代码。提前致谢