[eluser]Loquela[/eluser]
The query below seems to work fine, but when I print the result it always throws TWO "Trying to get property of non-object" errors before printing the rows out!
Any ideas why?
Code:
function menu_topics($data)
{
$this->db->select('pp_topics.topic_id,pp_topics.topic,pp_topic2subject.topic_id,pp_topic2subject.subject_id');
$this->db->from('pp_topics');
$this->db->join('pp_topic2subject', 'pp_topic2subject.topic_id = pp_topics.topic_id ');
$this->db->where('pp_topic2subject.subject_id', $data['subject_id']);
$query = $this->db->get();
if($query->num_rows() > 0) {
foreach($query->result() as $topics) {
$data[] = $topics;
}
return $data;
}
}
Code:
<?php foreach($topics as $r): ?>
<p><?php echo $r->topic; ?></p> <!-- Error on this line, but rows print successfully after error -->
<?php endforeach; }?>