我是 codeIgniter 的新手,我的数据库和下拉菜单有点问题。
我的模型
function list_kategori(){
$query = $this->db->get($this->table1);
$option = array();
foreach($query->result_array() as $row) {
$options[$row['id_cat']] =$row['categori'];
}
return $options;
}
我的控制器
public function listkategori(){
$data['kategori']=$this->Mtugasuas->list_kategori();
$data ['test'] = form_dropdown('kategori', $data);
}
我的观点
<?php
echo form_open('tugasuas/listkategori');
echo $test;
echo form_close();
?>
错误
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: test
Filename: blackcoffe/add.php
Line Number: 12
我究竟做错了什么?谢谢帮助