I have a drop down box like this:
<select name="DateDropDown">
<option value="2010 selected">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
</select>
I use the value that the user selects to refresh the page and perform a query on a database. Is there a better way than the following to keep the drop down box in the correct position?
<php?
echo '<select name="DateDropDown">';
if($MyDate = '2010')
{
echo '<option value="2010 selected">2010</option>';
}
else
{
echo '<option value="2010">2010</option>';
}
... same for each entry ...
</select>
?>
?
Thanks,
David