mysql_fetch_array() not displaying all results
        Posted  
        
            by 
                user1666995
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1666995
        
        
        
        Published on 2012-09-12T21:23:20Z
        Indexed on 
            2012/09/12
            21:38 UTC
        
        
        Read the original article
        Hit count: 276
        
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.
© Stack Overflow or respective owner