Re: drop down list of years puzzles me

From: Date: Tue, 20 Jan 2004 23:21:00 +0000
Subject: Re: drop down list of years puzzles me
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175230@lists.php.net to get a copy of this message
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" <bill@billgreen.org> wrote in message news:BC331F80.ABE%bill@billgreen.org... > 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 > --

« previous php.general (#175230) next »