I am trying to create a drop down menu for users to insert their orders into my database system.
I am having trouble creating the drop down menu, but I get the general idea of what I am supposed to do. I am new to this, so bear with me please.
Here is my uml if it helps:
<?php
$databaseName = 'pizza_db';
$databaseUser = 'root';
$databasePassword = 'root';
$databaseHost = '127.0.0.1';
$conn = new mysqli($databaseHost, $databaseUser, $databasePassword, $databaseName);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected sucessfully";
if(isset($_POST['submit'})){
$sql = "SELECT size FROM size";
$result = mysqli_query($sql);
$opt = "<select name='size'>";
while($row = mysqli_fetch_assoc($result)) {
$opt .= "option value='{$row['size']}' >{$row['size']}></option>";
}
$opt .="</select>";
if ($conn->query($sql)){
$msg = "Data inserted successfully";
} else{
$msg = "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Pizza</title>
</head>
<body>
<form action="size.php" method="POST">
<select name="size">
</select>
<button type ="submit" name="submit"> Submit</button
</form>
</body>
</html>
I know my html code is wrong or incomplete. How do I make it so that multiple drop down menus are created and how do I use multiple $sql insert statements in one script in order to submit my data into my database? Any help would be appreciated.