Using pre-populated drop down list in PHP to send output to INSERT

I am creating a form which when submitted sends the output to an INSERT statement. I am learning how to do this using:

<form action="somepage.php" method="post">
Example: <input type="text" name="something" />
<input type="submit" />
</form>

I am fairly comfortable doing this and then writing an INSERT statement containing $_POST.

I also have a field that I would like to present in a drop down which is populated with the results of a mysql_query, as below:

$sql = "SELECT name FROM customer";
$result4 = mysql_query($sql);

echo "<select name='name'>";
while ($row = mysql_fetch_array($result4)) {
echo "<option value='" . $row['name'] . "'>" . $row['name'] . "</option>";
}
echo "</select>";

However I am not sure how to use the value that the user selects. I.e. I would like to use the value that they select in my INSERT statement along with the other form fields.

How do I do this?

Comments 2

发表评论

电子邮件地址不会被公开。 必填项已用*标注