I have a database with a date field that I want to count the number of unique years and then how many entries for each year. Here is what I have:
while ($row = mysql_fetch_array($sql_result))
{
$Date = $row["Date"];
//DETERMINE YEARS
$Year = substr("$Date",0,4);
if (!in_array($Year, $allDates)){
$allDates[] = $Year;;
}
}
So this leaves me with an array containing all the unique years.
Array ( [0] => 2010 [1] => 2008 [2] => 2009 [3] => 2006 [4] => 2007 [5] => 2012 [6] => 2011 [7] => 2013 )
Now how do I loop through all the entries again and total up the number of records with that specific year?
Thanks in advance