I'm reasonably certain that I've titled this correctly, but you folks can tell me for sure.
I want to present a user with a list of years in a drop-down box. The list of years should be a range that:
1 - starts with the youngest parent's age plus three years
2 - excludes any years either parent has had children (query)
3 - ends with the present year
It's #2 that is giving me a problem.
1 is calculated this way:
if($row_PAsire['HorseYear'] > $row_PAmare['HorseYear']) { $baseyear=$row_PAsire['HorseYear'];}
if($row_PAsire['HorseYear'] <= $row_PAmare['HorseYear']) { $baseyear=$row_PAmare['HorseYear'];}
$startyear=($baseyear+3);
The query that produces the "excluded years" list for 2 is this:
$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);
I tried to pull it altogether like this:
foreach (range(($startyear), 2012) as $number) {
if(($number)!==$row_PAfoals['HorseYear'])
{echo '<option value="'.$number.'">'.$number.'</option>';}
}
But that does not work, and I'm assuming that's because $row_PAfoals['HorseYear'] is a query result with multiple rows. The $number is getting checked against the first row in the result set and that's the end of it. Therefore, even though a year might appear in the query result, it is not getting excluded from the drop-down list because the "if" condition for $number isn't checking all the rows in the result $PA_foals.
Is there a way to format that "if" condition so that it compares all rows in the result set, or alternatively, do I need to create two arrays and then produce a third that compares the results? If it's the latter, I am not sure how to go about that. From Google, it looks like "array_diff" might be useful but php.net is down, it appears, so I'm unable to read up on that at this time. Thanks in advance for any help.