Drop down box that auto populates years

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jmyers
Forum Newbie
Posts: 3
Joined: Sat Feb 12, 2005 8:33 pm
Contact:

Drop down box that auto populates years

Post by jmyers »

I am trying to have a drop down box that will auto populate each year starting from 1900 and ending with $currentyear

can someone please help

Thanks

Jeff
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

simple loop:

Code: Select all

$output = '';
for($x = 1900; $x <= $currentyear; $x++)
  $output .= '<option value="' . $x . '">' . $x . '</option>';
echo $output;
Post Reply