[eluser]Henry Weismann[/eluser]
I have just started with php MVC design pattern frameworks and after researching for a while I have decided to use CodeIgnitor. I have been using php for a few years now and have dabbled in OO techniques in other languages but it is still new to me. I am excited to learn a framework and work on application of OO ideas. Anyway I have what is probably a simple question. I have created a controller a model and a view but my view is giving an error when trying to output the results from my controller. This is the error:
Code:
Message: Undefined property: customerName
Filename: views/admin_customers_view.php
Line Number: 12
I am using a foreach for iteration. Here are snippets of my code:
The Model function:
Code:
function get_customers($limit,$offset)
{
$query = $this->db->get('customerinfo', $limit);
return $query->result();
}
The controller function:
Code:
function customers($limit = 25, $offset = 0)
{
$this->load->library('pagination');
$this->load->model('Admin_model');
$data['customer'] = $this->Admin_model->get_producers($limit, $offset);
// Pagination code
$config['base_url'] = '/admin/producers/'.$limit.'/';
$config['total_rows'] = $this->db->count_all('movieproducers');
$config['per_page'] = $limit;
$config['uri_segment'] = 4;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$this->load->view('admin_customers_view',$data);
}
}
In the view:
Code:
<ul>
<?php foreach($customer as $item):?>
<li><?=$item->customerName;?></li>
<?php endforeach;?>
</ul>
<br/><br/><?=$pagination ?></center>
Can anyone tell me what I am doing wrong. Is $data['customer'] an array or object. Maybe I am missing my fundamentals on iterating through an object.