I have a form that sends back to itself and checks for errors or missing fields. I have the countries in a pull down list and at present when ever the user returns to the page the country has reset itself to the first option.
I have tried to add an if statement in so if the value = the $_POST value the option will be selected. But I keep getting errors.
Here is the code so far
$sql = ("SELECT * FROM country");
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
extract ($row);
echo "<option value=\"$country_id\" " .
if($country_id == $_POST['country']) {
"selected" .
}
">$country_name</option>";
}
echo "</select>";
If anyone has any ideas it will be greatly aprreciated.
Thanks