Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to show data from within a specific time period in codeigniter?
  2. www.mydomain.com/blog/archive/2012-May
  3.        
  4. function get_archive_posts(){
  5.  
  6.     $data = '';
  7.  
  8. //NEED TO GROUP AND GET BY DATE AND YEAR IN URL
  9.  
  10.         $this->db->order_by('date','desc');
  11.         $query = $this->db->get('blog');
  12.         foreach ($query->result() as $row) {
  13.             $data[] = array(
  14.                 'id' => $row->id,
  15.                 'date' => $row->date,
  16.                 'title' => $row->title,
  17.                 'content' => $row->content,
  18.                 'category' => $row->category,
  19.                 'author' => $row->author
  20.             );
  21.         }
  22.         return $data;
  23.     }
  24.        
  25. function archieve($year='A_DEFAULT_VALUE_FOR_HERE', $month='A_DEFAULT_VALUE_FOR_HERE_TOO') {
  26.  
  27. //You can here use 3rd and 4th segments (example: $year=$this->uri->segment(3); $month=$this->uri->segment(4); ) as variables.
  28.  
  29. }