title: CodeIgniter - order my 'posts' by month?
body: <p>In my website I'd like to create an 'archive' list to categorise my posts.</p>
  
  <p>My <code>posts</code> table is set up like so:
  <strong>id | post_title | post | pubdate | year | month</strong></p>
  
  <p>Currently this <strong>model</strong> function pulls the posts:</p>
  
  <pre><code>function getNews(){
       $data = array();
       $this-&gt;db-&gt;order_by("id", "desc");
       $Q = $this-&gt;db-&gt;get('posts');
       if ($Q-&gt;num_rows() &gt; 0){
         foreach ($Q-&gt;result_array() as $row){
           $data[] = $row;
         }
      }
      $Q-&gt;free_result();  
      return $data;
  }   
  </code></pre>
  
  <p>However, is it possible I can create a list like the following?</p>
  
  <pre><code>July (12)
  
  June (5)
  
  May (2)
  </code></pre>
  
  <p>So it lists the month and the number of posts within that month?</p>
  
  <p>All my attempts thus far have ended in frustration and tears. Any help would be greatly appreciated.</p>