I am have this query below that is a drop down for year (from 1900-current). I am using a $variable to show a previously chosen year first in the drop down for an edit form. It works except that for all other years 2011 is also repeated with them. How do i tweak it so that $y shows first and then all years underneath that?
Code:
<select name="year">
<?PHP for($i=date("1900"); $i<=date("2011"); $i++)
if($year == $i)
echo "<option value='$y' selected>$y</option>
<option value='$i' selected>$i</option>";
else
echo "<option value='$y' selected>$y</option>
<option value='$i'>$i</option>";
?>
</select></td>
</tr>
Keep it simple:
Or even better:
And backwards