[eluser]mattnewark[/eluser]
Hi Everyone,
I'm trying to group dates together and show them in a view as previous news items,
Controller
Code:
$data['pnews'] = $this->site_model->get_previous_news();
Model
Code:
$this->db->order_by('date', 'asc');
$this->db->group_by('Month(date)');
$this->db->where('category', 1);
$query = $this->db->get('articles');
if ($query->num_rows() > 0)
{
return $query->row();
}
return FALSE;
View
Code:
<?php foreach ($pnews as $p) { ?>
<li><a href="#"><?php echo date('F Y', strtotime($p['date'])) ?></a></li>
<?php } ?>
I maybe doing something very wrong but I have no idea what it is, what is shown in the view is a list of dates but do not really relate to my test entries. Some of the dates are from January 1970 but there are more entries being produced than entries in db.
Does any one have any idea what I am doing wrong??
Thanks