纯新手,接触CI两三天,试着跟着视频教程做,跟用 CodeIgniter 开发新闻发布系统(上)这个视频做时,遇到一个问题
A PHP Error was encounteredSeverity: Notice Message: Undefined variable: row Filename: views/header.php Line Number: 14 A PHP Error was encounteredSeverity: Notice Message: Trying to get property of non-objec
我的代码部分是这样
function get_category()
{
$query = $this->db->query('SELECT * FROM category');
return $query->result();
}
function index()
{
$this->load->model('Mhome');
$data['category'] = $this->Mhome->get_category();
$data['pagetitle'] = "CI Develop";
$this->load->view('header',$data);
$this->load->view('index');
$this->load->view('footer');
}
<? foreach ($category as $row):?>
<li><a href="#" ><?php echo $row->category_name; ?></a></li>
<?endforeach ;?>
因为不能用脚手架,我就在phpmyadmin中手动添加了数据,但是出现了上面了错误,希望大神可以指导一下~~ |