I am trying to store the dates and month name from my database in this format. I am aiming to store the month and then count the entries in that month and then store the count. This is my loop, but I have trouble formatting the array properly.
while ( $row = mysql_fetch_assoc($res) ) {
if ($row['Date'] != $prev_date) {
$values=array(
$row['Date'] => $count,
);
$prev_date = $row['Date'];
}
$count++;
}
print_f($values);
You can see that I will always overwrite my previous array and I am not really adding entries into the array. I couldn’t figure out how to do it. I’m basically trying to see the number of entries per month.
OLD Update: Currently learning the MYSQL thing that one commenter mentioned. I’ll update when I get it.
I almost got it!
Update: Need a little help with this part.
My output:
999 was supposed to be stored in 9 and 986 was supposed to be stored in 10.
Update: Here’s my new code, I would appreciate it if someone can show me a more efficient way.
Output: