[eluser]Unknown[/eluser]
Hi !
I'm new to CI and PHP framework globaly.
I'm having an issue making a loop to display news in my view.
Code:
<?php foreach($news as $row => $val): ?>
<li>This is the title : <? echo $val->title; ?></li>
<li>This is the title : <? echo $row->title; ?></li>
<?php endforeach; ?>
These to echo displays the SAME thing (Oo ?) : "this is the title : title; ?>" instead of the real title.
Moreover, when I do the same directly in my controller, it works flawlessly... The error only is in th view, and I don't get why.
For info :
Controller :
Code:
$this->load->model('News_model', '', TRUE);
$viewData['news'] = $this->News_model->get_last_x_entries(10);
$this->load->view('includes/header');
$this->load->view('news/news_default', $viewData);
$this->load->view('includes/footer');
Model :
Code:
function get_last_x_entries($x)
{
$this->db->select('id, author_id, title, content, created_at');
$this->db->from('news');
$this->db->limit($x);
$query = $this->db->get();
return $query->result();
}
Thanks in advance.