mysql_fetch_array() not displaying all results
- by user1666995
I have a database with a calendar table (each row represents one day) with 4 years of rows (2012, 2013, 2014, 2015). I use the column name calyear for the year.
I use the following code to find values for distinct years then display it:
$year = mysql_query("SELECT DISTINCT calyear FROM calendar");
while($yeararray = mysql_fetch_array($year))
{
echo($yeararray['calyear']."<br />");
}
The problem is it only displays the years 2013, 2014, 2015 even though when I use
echo(mysql_num_rows($year);
it displays the value 4 which I take to mean all 4 years are there. I'm not quite sure where I'm going wrong with this.