让我的For Each
函数将数据库中的所有值显示到视图中有点麻烦。我哪里错了?不是后端专业人士,也不是我写的。数据库表极其简单,一列名为id
. 我想显示我的每一行。
我有一个自定义MY_Controller.php
文件,并且在其中_construct
我有这个,它在整个站点中全局填充变量。
$this->country_zones = $this->Studios_model->get_studios();
模型:
function get_studios()
{
//this will alphabetize them
$this->db->order_by('id', 'ASC');
$query = $this->db->get('gc_studio_zones');
foreach ($query->result() as $row)
{
$countries = $row->id;
}
return $countries;
}
在我看来:
<?php foreach($this->$country_zones as $country):?>
<li><?php echo $country['countries']->id;?></li>
<?php endforeach;?>
错误:
Cannot access empty property...etc