[eluser]Rein Van Oyen[/eluser]
That's it! Altough, it seems the $count_entries returns a number that is 1 higher then it should. So I get an "undefined offset" error. What's wrong here, do I just need to do something like this:
Code:
$count_entries = count($query_blog)-1;
I think that's not really handy to do everytime I run code simular to this. Any idea's?
This is my blogmodel:
Code:
function get_entries($limit='') /* gets a list of blogitems, limit can be specified */
{
if(empty($limit)){
$this->db->select('*')->from('blog_entries')->order_by('entry_id','desc');
}
else
{
$this->db->select('*')->from('blog_entries')->order_by('entry_id','desc')->limit($limit);
}
$query = $this->db->get();
if($query->num_rows()>0)
{
$blog_array = array();
foreach($query->result_array() as $row)
{
$blog_array['id'][] = $row['entry_id'];
$blog_array['date'][] = $row['entry_date'];
$blog_array['title'][] = $row['entry_title'];
$blog_array['body'][] = $row['entry_body'];
$blog_array['comments'][] = $this->commentmodel->count_comments('blog_entry', $row['entry_id']);
}
}
return $blog_array;
}
You've been a great help so far, step by step I begin to understand the framework. (yes, datamodels are still kinda hard, but I'll get there eventually) Thank you!