I want to list a dropdown menu in my HTML form, that the user can select the item they want, using a dropdown menu (based on items in database) I have researched a lot, and come to this as last resort! Please explain, and help.
it should look like: Select a Product: -dropdown menu- Quantity: 86
<html>
<head>
<title>BuyingTransaction</title>
</head>
<body>
<form action= "BuyingTransaction.php" method="post">
<select class="form-dropdown" style="width:150px" id="input_5"
name="ProductNames">
</form>
<?php
$username="22243339";
$password="X23CZw2X";
$server="localhost";
$database="DB_22243339";
$sqlConnect = mysql_connect($server, $username, $password);
// Check connection to the database
if(!sqlConnect)
{
die('Could not connect: ' . mysqlerror());
}
mysqli_select_db($sqlConnect, $database);
$filter = mysql_query("SELECT ProductName FROM Products", $sqlConnect);
menu = "";
while($row = mysql_fetch_array($filter))
{
$menu .="<option>" . $row['dropdown_option'] . "</option>";
}
// Close menu form
$menu = "</select></form>";
echo $menu;;
mysqli_close(sqlConnect);
?>
</select>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire