在视图中它得到了像未定义变量类别列表这样的错误,你能帮我吗!!!!!!!!!
控制器
public function categorylist()
{
$data['categorylist']=$this->userprocessmodel->categorylist();
$this->load->view('user/home',$data);
}
模型
public function categorylist()
{
$query=$this->db->get('category');
echo $query->num_rows();
if($query->num_rows()>0)
{
return $query->result();
}
else
{
return null;
}
}
看法
<?php
if($categorylist)
{
foreach($categorylist as $categorylist)
{
$categorylist->categoryname;
}
}
?>