View Single Post
Old 06-15-2011, 05:18 PM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,115
Lol, I just can't keep this out of my head dammit.

Okay, when we talked about it, you had said something about using 4 different dropdowns, one for each selected city and that you had the cities marked as 1, 2, 3, 4 in the city_display field.

I went in and created a new model_in_city table and named it model_in_city_mod and emulated the way you had that set up.

So you could do your 4 separate dropdowns kinda like this: http://www.madspiders.com/selecttest2.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);

$sel=array();

$id = 1;
$query="select a.city_id, a.city_name, b.city_display from city a ";
$query  .="left outer join model_in_city_mod 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) 
{
    for($i=1;$i<=4;$i++)
    {
      $sel[$i]="<select name=select[" . $i . "] size=8>\n";
    }
    while ($cityrow = mysql_fetch_array($city_result)) 
    {
      for($i=1;$i<=4;$i++)
      {
        $sel[$i].="<option value=" . $cityrow['city_id']; 
        if($cityrow['city_display']==$i)
        {
          $sel[$i] .=" selected ";
        }
        $sel[$i].=">" . $cityrow['city_name'] . "</option>\n";
      }
    }
    for($i=1;$i<=4;$i++)
    {
      $sel[$i].="</select>";
    }
}
else
{
  echo "no city result mysql error=" . mysql_error() . "<br>\n";
}
for($i=1;$i<=4;$i++)
{
  echo $sel[$i] . "<br>\n<br>\n";
}
?>
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote