<?php include "../../mainfile.php"; $county=$_POST['county']; $def_city=$_POST['city']; $sql = "select city from `" . $xoopsDB->prefix("phone_book") . "` where county='{$county}' group by city order by zip"; $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error()); echo "<option value=''>選擇鄉鎮市區</option>"; while (list($city) = $xoopsDB->fetchRow($result)) { $selected=($city==$def_city)?'selected':''; echo "<option value='{$city}' $selected>{$city}</option>"; }