This should help:
<?php
$curr_year = intval(date('Y'));
$range = 10+$curr_year;
for ($y=$curr_year; $y < $range; $y++) {
echo "<option value={$y}>".$y."</option>\n";
}
?>
What you forgot is that $range must be the current year plus how many loops
you want.
Eric
"Bill Green" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> This works to create a drop down select box of numbers 1-12:
>
> for($i=1; $i < 13; $i++) {
> echo "<option value={$i}>".$i."</option>\n";
> }
>
> This doesn't to create a drop down box of years:
>
> $curr_year = intval(date('Y'));
> $range = 10;
> for ($y=$curr_year; $y < $range; $y++) {
> echo "<option value={$y}>".$y."</option>\n";
> }
>
> When I check for errors:
> $curr_year = 2004
> $curr_year is an integer
> $range = 10
> $curr_year + $range = 2014
> $y = 2004
>
> But my select box is empty... as in:
> <select name='yada'>
> </select>
>
> What is it that I don't understand?
>
> --
> Bill
> --
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php