I have a form that uses a dropdown menu to display countries. Upon selection, the user will be taken to the relevant url. I'm building the dropdown menu options via a query to mysql, and I'm trying to get it to default to 'selected' for the 'United States'. But, the code below isn't working and I'm not sure why. Can someone help?
<tr>
<td height="27" valign="top">
<div style="padding-left:0px; padding-top:0px ">
<select name="country" onChange="window.location=document.countrySelect.country.options[document.countrySele
ct.country.selectedIndex].value" style="width:140px; height:19px " class="policy">
<?
$query = "SELECT DISTINCT Country FROM Countries ORDER BY Country ASC";
$result = @mysql_query($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
if ($row['Country'] == 'United States') {
echo "<option value=\"url.php?country={$row['Country']}\" selected>{$row['Country']}</option>\n";
} else {
echo "<option value=\"url.php?country{$row['Country']}\">{$row['Country']}</option>\n";
}
/* Code truncated */