Can some body help me with this drop down list function?
I'm new to PHP and any help is greatly appreciated.
i created a function to pull data from mySQL and then create a drop down box to display it. for some reason, the options are not in the drop down, they are text outside of the dropdown.
Below is the script that i use.
/**************
function displayUsersDropDown($Where){
global $database;
$q = "SELECT username "
."FROM ".TBL_USERS;
$q = $q." ".$Where." ORDER BY userlevel DESC,username";
$result = $database->query($q);
/ Error occurred, return given name by default /
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
echo "<option value=\"Error displaying info\">Error displaying info</option>";
return;
}
if($num_rows == 0){
echo "<option value=\"Database table empty\">Database table empty</option>";
return;
}
echo "<select>";
/ Display table contents /
for($i=0; $i<$num_rows; $i++){
$uname = mysql_result($result,$i,"username");
echo "<option value=\"".$uname."\">$uname</option>";
}
echo "</select>";
}
**************/
the text come out like this
<select name="deluser"><option value="rngo11@clearonedebt.com">rngo11@clearonedebt.com</option><option value="rngo1@clearonedebt.com">rngo1@clearonedebt.com</option><option value="rngo@clearonedebt.com">rngo@clearonedebt.com</option></select><input type="hidden" name="subdeluser" value="1">
i tried other editor and the options show up in the dropdown while my page does not show them int he dropdown. Am I doing something wrong?
Thank you for your help in advance.