newb Posted December 1, 2011 Share Posted December 1, 2011 How can I make this output in descending order from greatest to least? Right now, it appears like: 1940 1941 1942 1943 1944 etc... i'd like it to be like 2012 2011 2010 2009 etc.. until it gets to 1940 any ideas? here is my code: <? $i = 1939; while ($i < 2012) { $i++; echo '<option value="'.$i.'">'.$i.'</option>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/252172-output-loop-results-in-descending-order/ Share on other sites More sharing options...
denno020 Posted December 1, 2011 Share Posted December 1, 2011 You could swap the 1939 and 2012, then have the variable decrement? $i = 2012; while($1 > 1939){ $i--; echo 'whatever'; } Denno Quote Link to comment https://forums.phpfreaks.com/topic/252172-output-loop-results-in-descending-order/#findComment-1292866 Share on other sites More sharing options...
newb Posted December 1, 2011 Author Share Posted December 1, 2011 yep, thanks Quote Link to comment https://forums.phpfreaks.com/topic/252172-output-loop-results-in-descending-order/#findComment-1292867 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.