the following code creates an select (drop down). note that only one item will match the
user_comboID from the last submit and this will be selected from the list retrieved from the database. NB: SELECTED is the key!!!
$query = "SELECT * FROM auth_users";
$result = mysql_query($query) or die("Couldn't create users list.");
while ($myrecord = mysql_fetch_array($result)) {
$enum_userID = $myrecord['userID'];
$enum_username = $myrecord['username'];
$enum_userfname = $myrecord['f_name'];
$enum_userlname = $myrecord['l_name'];
if ($enum_userID == $userID_combo) {
$option_block .= "<option value=\"".$enum_userID."\" selected>".$enum_userfname." ".$enum_userlname." (".$enum_username.")</option><br>\n";
}else{
$option_block .= "<option value=\"".$enum_userID."\">".$enum_userfname." ".$enum_userlname." (".$enum_username.")</option><br>\n";
}
}
below is the corresponding html that
<FORM NAME="users" METHOD="post" action= <? print "$PHP_SELF"."?".SID; ?>>
<select name="userID_combo">
<? echo "$option_block"; ?>
</select>
<INPUT TYPE="SUBMIT" NAME="delete_user" VALUE="Delete User">
</FORM>
need more info?