In my website I'd like to create an 'archive' list to categorise my posts.

My `posts` table is set up like so:
**id | post\_title | post | pubdate | year | month**

Currently this **model** function pulls the posts:

```
function getNews(){
     $data = array();
     $this->db->order_by("id", "desc");
     $Q = $this->db->get('posts');
     if ($Q->num_rows() > 0){
       foreach ($Q->result_array() as $row){
         $data[] = $row;
       }
    }
    $Q->free_result();  
    return $data;
}   

```

However, is it possible I can create a list like the following?

```
July (12)

June (5)

May (2)

```

So it lists the month and the number of posts within that month?

All my attempts thus far have ended in frustration and tears. Any help would be greatly appreciated.