Home now,
as I said in icq, that version was so you could see what was happening all the way through.
To do it from one query like you were trying to do would look like this:
http://www.madspiders.com/selecttest1.php
Code:
<?php
//error_reporting(0);
$dbhost = "XXXXX";
$dbuser = "XXXXX";
$dbpass = "XXXXX";
$db = mysql_connect($dbhost, $dbuser, $dbpass);
$dbname="select_test";
$selected=mysql_select_db($dbname);
// for testing
$id = 1;
$query ="select a.city_id, a.city_name, b.city_display from city a ";
$query .="left outer join model_in_city b on a.city_id=b.city_id and b.city_display>0 and b.model_id=" . $id . " ";
$query .="order by a.city_name";
$city_result=mysql_query($query,$db);
if ($city_result)
{
echo "<select name=select multiple size=8>";
while ($cityrow = mysql_fetch_array($city_result))
{
echo "<option value=" . $cityrow['city_id'];
if($cityrow['city_display']==1)
{
echo " selected ";
}
echo ">" . $cityrow['city_name'] . "</option>";
}
echo "</select>";
}
else
{
echo "no city result mysql error=" . mysql_error() . "<br>\n";
}
?>
You said on yours that it was not marking the options as selected. When you get back, post up the actual code you have so we can take a look.
.