我有一个从 codeigniter 中的汽车模型数据库填充的下拉列表。
当用户在下拉列表中选择值(例如雷克萨斯、本田等)时,应加载所选制造商的汽车列表。然而,没有任何效果。这是我当前的代码。
//controller
public function carsPage() {
$this->load->model('model_users');
$data3['images'] = $this->model_users->getRow();
$data['tags'] = $this->model_users->get_dropdown_tags();
$newData = array_merge($data, $data3);
$this->load->view('cars', $newData);
}
//model
function get_dropdown_tags() {
//select distinct car_make from cars
$tags = $this->db->query("SELECT distinct car_make from cars");
$dropdowns = $tags->result();
foreach ($dropdowns as $dropdown)
{
$dropdownlist[$dropdown->car_make] = $dropdown->car_make;
}
$finaldropdown = $dropdownlist;
return $finaldropdown;
}