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"; Link to comment https://forums.phpfreaks.com/topic/214567-change-drop-down-list-from-current-to-past-years-to-current-to-future-years/ 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>"; } Link to comment https://forums.phpfreaks.com/topic/214567-change-drop-down-list-from-current-to-past-years-to-current-to-future-years/#findComment-1116625 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--) Link to comment https://forums.phpfreaks.com/topic/214567-change-drop-down-list-from-current-to-past-years-to-current-to-future-years/#findComment-1116964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.