I want to count the number of posts for each day to create a graph. My problem is that since SQL doesn't find results for some days (Count is 0), I'm missing rows I need for the chart (since I do want to show days with no posts).
SELECT DATE(Date) AS Day, COUNT(*) AS COUNT
FROM `Posts`
GROUP By `Day`
ORDER BY Date DESC
while($row = mysql_fetch_array($result)) {
echo $row['Date'] . ": " . $row['Count'];
}
Since the loop doesn't display days with 0 results, if on wednesday there are no posts I get: monday-17-3: 5, tuesday-18-3: 2, thursday-20-3: 3
. Instead I want to fill out the blanks so I get something like: wednesday-19-3: 0
.
How can I echo the days with no results in the loop?