DOB drop down issue
Moderator: General Moderators
-
benjaminj88
- Forum Newbie
- Posts: 21
- Joined: Fri May 02, 2008 2:31 pm
DOB drop down issue
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
Let's see your code so it can be critiqued.
Re: DOB drop down issue
It's as simple as:
It's probably a small logic error in your code. Post the code if you were going for something else.
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>-
benjaminj88
- Forum Newbie
- Posts: 21
- Joined: Fri May 02, 2008 2:31 pm
Re: DOB drop down issue
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.