I am very new to this and am using php and MySQLi to create a form which will create a record in a third table. This works fine but I can't help but think that there is a way to do it with a single query rather than a query for each table as I have now. The third table is called tblcars, and I will use this form to build records for that table by selecting data from these dropdowns.
<?php
//Database Login
require_once 'includes/connection.php';
$sql = ("SELECT * FROM tblmake");
$getclass = ("SELECT * FROM tblclass");
$result = $conn->query($sql);
$results = $conn->query($getclass);
?>
<html>
<head>
<title>Car Makes</title>
</head>
<body>
<h3>Car Makes</h3>
<form action="" method="get">
<select name="makeID">
<option value="">Choose Make</option>
<?php
while($make = $result->fetch_assoc()) {
echo "<option value={$make['makeID']}>";
echo $make['carmake'];
echo "</option>";
}
?>
</select>
<select name="classID">
<option value="">Choose Class</option>
<?php
while($class = $results->fetch_assoc()) {
echo "<option value={$class['classID']}>";
echo $class['carclass'];
echo "</option>";
}
?>
</select>
<input type="submit" value="Insert">
</form>
</body>
</html>