I'm running the following query on my table:
SELECT DISTINCT(date(dateAdded)) AS dateAdded, count(*) AS count FROM clients WHERE (dateAdded BETWEEN '2012-06-15' AND '2012-06-30') GROUP BY dateAdded ORDER BY dateAdded ASC
That returns something like this:
2012-06-17 ¦ 5
2012-06-19 ¦ 2
2012-06-26 ¦ 3
2012-06-30 ¦ 2
I need to be able to fill in any missing dates in the date range like so:
2012-06-15 ¦ 0
2012-06-16 ¦ 0
2012-06-17 ¦ 5 <--
2012-06-18 ¦ 0
2012-06-19 ¦ 2 <--
2012-06-20 ¦ 0
2012-06-21 ¦ 0
2012-06-22 ¦ 0
2012-06-23 ¦ 0
2012-06-24 ¦ 0
2012-06-25 ¦ 0
2012-06-26 ¦ 3 <--
2012-06-27 ¦ 0
2012-06-28 ¦ 0
2012-06-29 ¦ 0
2012-06-30 ¦ 2 <--
I'd like to do this using a PHP loop of some sort, if possible. Any help would be greatly appreciated.