[eluser]Medikal[/eluser]
Hey guys, first time poster here. Extremely new to codeigniter, decided to take a chance with it as it seemed alot more intuitive than zend/cakephp. I have to say the support on the forums and the extremely vast user guide is absolutely amazing, and has already helped me through alot as I'm teaching myself.
I ran into a minor error, not sure exactly why I get the error:
Message: Invalid argument supplied for foreach()
My model:
Code:
function listposts()
{
$query = $this->db->get('posts');
if ($query->num_rows() > 0)
{
return $query->result();
}
}
My controller:
Code:
function index()
{
$data['rows'] = $this->posts_model->listposts();
$this->load->view("index_view", $data);
}
and the view, erroring at line 10: (the foreach line)
Code:
<?php
foreach ($rows as $row) {
echo '<h1>' . $row['title'] . '</h1><br>
' . $row['text'] . '';
}
?>