$r=mysql_query("SELECT city.id as city_id,city.city_name,locality.id,locality.area_name ".
"FROM city, locality ".
"WHERE city.id = locality .city_id order by city_id");
$previous = '';
while($rss=mysql_fetch_object($r)) { ?>
<?php if (empty($previous) || $previous != $rss->city_id) { ?>
<legend><?=$rss->city_name?></legend>
<?php } ?>
<?php $previous = $rss->city_id; ?>
<input type="checkbox" name="sub_type[]" id="sub_type" value="<?=$rss->id?>" />
<span><?=$rss->area_name?></span><br/>
<?php
}
?>
這是我的城市名稱和地區名稱記錄在列表中下拉列表中現在我想顯示同樣的東西在城市名稱在紅色的選擇框,然後其子區域名稱它的小示例是http://www.99acres.com/,因爲該站點上的城市顯示選擇兩種類型的選項值
請重新格式化您的代碼可讀性更好 – Nazariy