Honestly, the easiest and smartest way to do this is to add a table to your DB that has one record for every year and month.
Something like this:
TABLE: allMonths
monthYear DATETIME
and then have entries in it such as
1/1/2008
2/1/2008
3/1/2008
...
12/1/2008
1/1/2009
..
...
12/1/2029
And then you do
SELECT AM.monthYear, ...fields from other table[s]...
FROM allMonths AS AM LEFT JOIN yourTable AS T
ON ( Year(AM.monthYear) = Year(T.someDateField)
AND Month(AM.monthYear) = Month(T.someDateField)
...
I show this in a "Calendar of Events" where I create one record per *day* in order to show all dates in a given range. Here, on my demos page:
http://www.ClearviewDesign.com/Newbie
That's for ASP code, but the principle works the same for PHP, JSP, ASP.NET, etc.