MySQL Forums
Forum List  »  PHP

Re: Creating a Dynamic dropdown menu from MYSQL db
Posted by: Bob Field
Date: February 18, 2006 10:12AM

Use mysql_fetch_assoc() instead:

$query = "SELECT S_ID, Name FROM student";
$result = mysql_query($query, $mysql_link);
if(mysql_num_rows($result)) {
while($row = mysql_fetch_assoc($result))
{
print("<option value=\"$row['S_ID']\">$row['S_ID'], $row['Name']</option>");
}
} else {
print("<option value=\"\">No students created yet</option>");
}

Options: ReplyQuote


Subject
Written By
Posted
Re: Creating a Dynamic dropdown menu from MYSQL db
February 18, 2006 10:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.