I am trying to create a drop-down box that lists a range of years, but excludes years that are in the query result PAfoals. The problem I am having currently is that I am not getting all the values from the query result into an array ($noyears).
The query is here:
$query_PAfoals = sprintf("SELECT HorseYear from Pedigrees WHERE Dam=%s", GetSqlValueString($showmare,"int"));
$PAfoals = mysql_query($query_PAfoals, $CR) or die(mysql_error());
$row_PAfoals = mysql_fetch_assoc($PAfoals);
This query result contains 2005, 2006, and 2007.
The arrays are here:
$years=range('2000', '2008');
$noyears=array();
$noyears[]=$row_PAfoals['HorseYear'];
$openyears = array_diff($years, $noyears);
foreach ($openyears as $yearval)
{
echo $yearval.'<br/>';
}
The output from $openyears is:
2000
2001
2002
2003
2004
2006
2007
2008
As you can see, the only year excluded from the list is the first row in the query result set, 2005. array_diff is not excluding 2006 or 2007 because the array from the query result only contains one element - 2005. When I do this:
print_r($noyears)
I am only getting 2005 as output. I would like to know why I am not getting the entire query result set into the $noyears array. Thank you in advance for any help! 🙂