Hi all,

small problem. I use the below code to generate a drop down list, built from a database table:

PHP Code:
<?php 
//Display list of all types
$query_vestigingen="SELECT vestiging_id, vestiging FROM vestigingen WHERE dealer_id = '$dealer_id'";
                
$result_vestigingen mysql_query($query_vestigingen);
echo 
"<select name=vestiging_id value=''>vestiging</option>";
                
while(
$nt=mysql_fetch_array($result_vestigingen)){
echo 
"<option value=$nt[vestiging_id]>$nt[vestiging]</option>";
}
echo 
"</select>"
?>
This works fine. My question is, how can I detect the value which is actually mentioned in the database and have the drop down automatically display the right value ? I have a page where I need to update the values for a specific car, so for the update page, I need the dropdown list to show the saved data which is in the db.

I tried like this, but I can't make it work, I'm stuck I guess with the ' and the "

PHP Code:
echo "<option value=$nt[vestiging_id] if ($nt[vestiging_id] == $vestiging_id_db) echo 'selected'>$nt[vestiging]</option>"
where $vestiging_id_db is the value which is mentioned in the db. So I would like the drop down box to display the value $vestiging_id_db.

Any ideas why it doesn't work?

Kind regards,
Michel