Page 1 of 1
DOB drop down issue
Posted: Fri May 02, 2008 2:35 pm
by benjaminj88
Alright well I am currently trying to make a registration page for my website, and I would rather not sit there coding each year going back 100 years. So I made my attempts at creating a drop down menu with php using the -- decrement from the current year and working with while statements but my code keeps generating just the drop down menu with the first entry i made before placing my decrement/loop. Can anyone help me out here?
Re: DOB drop down issue
Posted: Fri May 02, 2008 2:38 pm
by lafever
Let's see your code so it can be critiqued.
Re: DOB drop down issue
Posted: Fri May 02, 2008 2:41 pm
by Verminox
It's as simple as:
Code: Select all
<select name="year" id="year">
<?php
$current_year = (int)date("Y");
for($i=$current_year; $i>=($current_year-100); $i--)
{
echo "<option value='$i'>$i</option>";
}
?>
</select>
It's probably a small logic error in your code. Post the code if you were going for something else.
Re: DOB drop down issue
Posted: Fri May 02, 2008 7:28 pm
by benjaminj88
wow thanks a lot, found the problem finally after comparing the two, was pretty lame that I messed up on a simple error, but i doubt I would have caught it anyways thanks again, saved me a lot of time, and saved my page from being so long.