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>'; } ?> 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 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 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
Archived
This topic is now archived and is closed to further replies.