Michael Michael - 1 year ago 64
PHP Question

How to make PHP for loop to count down instead of up?

I am using PHP to create a dropdown box with years from 1900 to 2012. However, I'd like to have 2012 at the top of the list (i.e. count down from 2012 to 1900 instead of up from 1900 to 2012).

Any help you can provide would be great! :)

<select id="year">
<option value="">----</option>
for ($i = 1900; $i <= 2012; $i++){
echo '<option value="'.$i.'">'.$i.'</option>';

Answer Source
for($i = 2012; $i >= 1900; $i--)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download