acctman Posted May 28, 2009 Share Posted May 28, 2009 hi i'm trying to reverse the order of the output, its displaying 1930 -> 1991 in the selectbox. i'd like would like to have the output display from 1991 -> 1930 <?php for ($k = 1930; $k <= (date("Y") - 18); $k++) echo '<option value='.$k.'>'.$k.'</option>'; ?> Link to comment https://forums.phpfreaks.com/topic/160036-solved-selectbox-reverse-output/ Share on other sites More sharing options...
lonewolf217 Posted May 28, 2009 Share Posted May 28, 2009 <?php for ($k = (date("Y") - 18); $k >= 1930; $k-- { echo '<option value='.$k.'>'.$k.'</option>'; ?> } i think that would work Link to comment https://forums.phpfreaks.com/topic/160036-solved-selectbox-reverse-output/#findComment-844236 Share on other sites More sharing options...
Ken2k7 Posted May 28, 2009 Share Posted May 28, 2009 Parse error on lonewolf217's code. <?php for ($k = date('Y') - 18; $k >= 1930; $k--) echo '<option value='.$k.'>'.$k.'</option>'; ?> Link to comment https://forums.phpfreaks.com/topic/160036-solved-selectbox-reverse-output/#findComment-844238 Share on other sites More sharing options...
lonewolf217 Posted May 28, 2009 Share Posted May 28, 2009 sorry bad copy/pasting there Link to comment https://forums.phpfreaks.com/topic/160036-solved-selectbox-reverse-output/#findComment-844247 Share on other sites More sharing options...
acctman Posted May 28, 2009 Author Share Posted May 28, 2009 thanks, that worked perfectly. Link to comment https://forums.phpfreaks.com/topic/160036-solved-selectbox-reverse-output/#findComment-844252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.