You can do this directly in SQL with an appropriate GROUP BY query.
The trick is this little expression. Given any DATE or DATETIME`, it yields the first day of the month.
DATE(DATE_FORMAT(datevalue, '%Y-%m-01'))
The query uses that formula a lot to figure things out.
Try this:
SELECT COUNT(id) AS idcount,
DATE(DATE_FORMAT(date, '%Y-%m-01')) AS month_beginning
FROM table
WHERE date >= DATE(DATE_FORMAT(NOW(), '%Y-%m-01')) - INTERVAL 12 MONTH
AND date < DATE(DATE_FORMAT(NOW(), '%Y-%m-01')) + INTERVAL 1 MONTH
GROUP BY DATE(DATE_FORMAT(date, '%Y-%m-01'))
ORDER BY DATE(DATE_FORMAT(date, '%Y-%m-01'))
This gives back one row for each of the most recent twelve months.
Here's a more extensive writeup on this kind of summary query. http://www.plumislandmedia.net/mysql/sql-reporting-time-intervals/