Hello,
I'm having a little problem with grabbing data from a MySQL database, and formatting the results in a <select> form.
I'm selecting a list of the 50 states from my database, I'd like to have the option automatically selected depending on which state the user is in.
Here's what I'm using now:
$states = "select abbr,full from eteam_states order by full";
$states_res = mysql_query($states) or die(showerror());
while ($wow = mysql_fetch_array($states_res)) {
$abbr = $wow['abbr'];
$full = $wow['full'];
// displays country twice in select form FIX THIS
if ($abbr == $state) {
echo "<option selected value='$abbr'>$full</option>";
}
echo "<option value='$abbr'>$full</option>";
}
... it works okay, but it will produce the selected state TWICE
Any ideas how I can clean that up, and have every state only display once, including the selected one?
Thanks