
Untitled
By: a guest on
Jul 20th, 2012 | syntax:
None | size: 0.88 KB | hits: 10 | expires: Never
How to show data from within a specific time period in codeigniter?
www.mydomain.com/blog/archive/2012-May
function get_archive_posts(){
$data = '';
//NEED TO GROUP AND GET BY DATE AND YEAR IN URL
$this->db->order_by('date','desc');
$query = $this->db->get('blog');
foreach ($query->result() as $row) {
$data[] = array(
'id' => $row->id,
'date' => $row->date,
'title' => $row->title,
'content' => $row->content,
'category' => $row->category,
'author' => $row->author
);
}
return $data;
}
function archieve($year='A_DEFAULT_VALUE_FOR_HERE', $month='A_DEFAULT_VALUE_FOR_HERE_TOO') {
//You can here use 3rd and 4th segments (example: $year=$this->uri->segment(3); $month=$this->uri->segment(4); ) as variables.
}