Hello All,
I'm wondering if it's possible to have a multiple select box default with the selected items from the database.
I have the user selecting multiple descriptions of a home lot location (CORNER, WATERFRONT or INTERIOR, CUL-de-SAC, etc.). When they need to go back into the admin tool to change something, I'd like the muliple select box to default to their original selections. I know how to do this with a standard dropdown, but am stumped as to how to do this with the "multiple" facet involved.
The selections are stored in the database with the IMPLODE function and are comma-separated. So they are in the database like this: CORNER, WATERVIEW. Is it possible to modify the below code?
<select MULTIPLE name="lot_description[]">
<?
$query = "SELECT ID, description FROM lot_description";
$result = mysql_query($query);
$desc = $HTTP_GET_VARS["desc"]; <--- this is passed from a form and comes across with a comma-delimited line from the db
while($row = mysql_fetch_row($result)) {
$description = $row[0]; <-- I do not need the ID number
$description = $row[1];
$selected = "";
if ($description == "$desc") { <-- HERE'S THE FAILURE, OF COURSE
$selected = "selected";
}
echo "<option $selected value=\"$description\">$description</option>\n";
}
?>
</select>
I'm drawing a blank. Any suggestions will be greatly appreciated!
Thanks.
Geogal