On Wednesday, January 21, 2004, at 10:10 AM, Bill Green wrote:


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";
}

Stop and read the for loop. You're saying "starting with the current year, increment, as long as the range is less than *10*."


Unless you have a time machine, the year will always be greater than "10" :P

$y = intval(date('Y'));
$range = $y + 10;
for ($y < $range)
{
    echo "<option value='{$y}'>{$y}</option>\n";
        $y++;
}


Justin French


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to