I am populating a drop down menu from the database.
It works.
Question --> During an EDIT/UPDATE screen : How do I get the CURRENTLY SELECTED item from the table to appear as the SELECTED or the FIRST ITEM in the drop down menu.
If the user DOES NOT EDIT this choice, I dont want it to write to the database with the default or first item, but instead to remain unchanged.
<?php
// create SQL statement to populate the CLIENT drop down menu
$sql09 = "SELECT * FROM client_table WHERE client_status=1 ORDER BY client_name ASC";
// execute SQL query and get result
$result09 = mysql_query($sql09,$conn) or die(mysql_error() . "result");
// put data into drop-down list box
while ($row = mysql_fetch_array($result09)) {
$client_name = $row["client_name"];
$clientID = $row["clientID"];
$option_block_client .= "<option value=\"$clientID\">$client_name</option>";
}
?>
<select name="job_client" id="client_name">
<? echo "<option value=\"0\" selected>Select Client</option>";?>
<? echo "$option_block_client"; ?>
</select>
At this time it will change the value to "0".
Please help