Hello-
I have a select drop down box on a form which is populated from a table. The table,categories, only holds the options for the select field. It works fine to submit the information, but I want the user to be able to return to the form and see the drop-down box with their previous choice highlighted (selected). That is, they will see what selection was stored in a table (not the table that stores the options for the select field) and be able to update their selection. But I can't figure out how to do it. Below is my code. Any help would be appreciated. Thanks very much.
<?php
//code that populates the select field
$sql = "SELECT * FROM categories ORDER BY cats ASC";
// execute SQL query and get result
$result = mysql_query($sql);
// put data into drop-down list box
while ($row = mysql_fetch_array($result)) {
$i = $row["cats"];
$option_block_cats .= "<OPTION value=\"$i\" selected>$i</OPTION>";
}
<form action="do_form.php" method="POST">
//the select drop down box
echo("<p>If you wish, update the Employment Category that you are looking to work in. <br>
<SELECT name=categories size=4>
$option_block_cats .
</SELECT>
<input type=submit name=SUBMIT value=SUBMIT>
?>