I can populate a drop down but can't figure out how to display the current option "selected".
I have this so far.
$q1 = mysql_query("select * from table_1");
$qry = mysql_fetch_array($q1)) ;
$grp=$qry[grp];
$q2 = mysql_query("select * from table_2");
if (mysql_num_rows($q2)) {
while ($qry2 = mysql_fetch_array($q2)) {
$groupid=$qry2[id];
$groupname=$qry2[name];
if ($groupid == $grp) { $sel = 'selected'; }
print "<select size=1 name=group>";
print "<option $sel value='$groupid'>$groupname</option>\n";
print "</select>";
} else { print "whatever here"; }
Now, the list drops in nicely but when the 'selected' catches, everything after it is also "selected" and by default, the last one in the list is always displayed as being the selected option.
Obviously I need to do this a different way, can anyone help?
Thanks