[eluser]barisv[/eluser]
Hi,
I am trying to show messages that comes from customers to the admin from contact page. But when I'm trying to retrieve data, it gives me an error sth like "trying to get property of non-object".
I couldnt figure out what I doing wrong. When I retrive data by using CI table class, it works just fine, but when I trying to retrieve data one by one, it doesnt work.
The related function of the controller
Code:
function musteri_mesajlari()
{
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/adminpanel/admin/musteri_mesajlari';
$config['total_rows'] = $this->db->get('messages')->num_rows();
$config['per_page'] = '10';
$this->pagination->initialize($config);
$data = array(
'main_content' => 'musteri_mesajlari',
'username' => $this->session->userdata('username'),
'records' => $this->db->get('messages', $config['per_page'], $this->uri->segment(3))
);
$this->load->view('includes/admin_template',$data);
}
The related view
Code:
<div id="main">
<?php if(isset($records)) :
foreach($records as $row)
{
echo $row->name;
}
?>
<?php else : ?>
No records were returned.
<?php endif; ?>
<?php echo $this->pagination->create_links(); ?>
</div>
Thanks in advance.