Having a bit of trouble getting my For Each function to display all the values from a DB into a view. Where am I going wrong? Not a back-end pro, nor did I write it. Database table is extremely simple, one column named id. I want to display each of the rows in my for each.
I have a custom MY_Controller.php file and in the _construct I have this, which fills in variables globally across the site.
$this->country_zones = $this->Studios_model->get_studios();
Model:
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;
}
In my view:
<?php foreach($this->$country_zones as $country):?>
<li><?php echo $country['countries']->id;?></li>
<?php endforeach;?>
Error:
Cannot access empty property...etc