Lisa23 Posted September 28, 2010 Share Posted September 28, 2010 Hi i have this drop down list current the year is 2010 and downwards but i want to change the list to 2010 upwards u can notice on the 50-- so shows current year minus so current is 2010 to 61 how can i change 2010 to 2030 or sunfin?? echo '<select name="year_of_birth">',"\n"; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { if($i == $thisYear) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n"; } echo '</select>',"\n"; Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 28, 2010 Share Posted September 28, 2010 $year = range(2010, 2061); // creates array with all values from 2010 through 2061 echo '<select name="year_of_birth">',"\n"; foreach( $year as $v ) { echo "<option value=\"$v\""; if( $v == $thisYear ) { echo ' selected="selected"'; } echo ">$v</option>"; } Quote Link to comment Share on other sites More sharing options...
Lisa23 Posted September 29, 2010 Author Share Posted September 29, 2010 Thank you very much i managed to fix by changing this line moe than to less - made plus and minus minus made plus plus but thnak u very much for ($i = $year;$i > $year-50;$i--) to for ($i = $year;$i < $year-50;$i--) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.