I have this code in my Model page:
public function getAll($researcherpk){
$this->db->select('*');
$this->db->from('research');
$this->db->join('researcher', 'researcher = lastname');
$this->db->where('researcherpk', $researcherpk);
return $this->db->get()->row_array();
But when I use it on my View Page
Age: <?php echo $data['age'];?> // this work
<?php foreach ($data as $v){ ?> //this has an error
<tr>
<td><?php echo $v->title?></td>
<td><?php echo $v->track_records?></td>
</tr>
<?php } ?>
I get the error:
Message: Trying to get property of non-object
In my Controller page:
public function researcher($researcherpk){
$this->load->model('ResearchModel');
$result['data'] = $this->ResearchModel->getAll($researcherpk);
$this->load->view('researcher',$result);
}
What do you think is the problem here? What is my alternative solution for it or changes?