I have a drop down menu populated with customer names from a MySQL table like so.
<?php
require_once ('./mysql_connect.php'); // Connect to the database
function build_customer1() {
$query = "SELECT customer, cust_id FROM customer ORDER BY 'customer'";
$result = @($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
extract($row);
$output .= "<option value=$cust_id>$customer</option>";
}
return $output;
}
?>
<select name="customer" id="customer">
<option value="">-</option>
<? echo build_customer1() ?>
</select>
When the form is submitted, I need the value that was selected by the user to be set as the selected value in the drop down menu so that if certain conditions in the form are not met the user does not need to reselect the values in the menu. Seems simple and thought I was better than this, but having great difficulty. Any help greatly appreciated.