<?
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header("content-type: application/x-javascript; charset=tis-620");
$data=$_GET['data'];
$val=$_GET['val'];
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "1234";
$dbname = "realestate";
mysql_pconnect($dbhost,$dbuser,$dbpass) or die ("Unable to connect to MySQL server");
if ($data=='province') {
echo "<select name='province' onChange=\"dochange('amper', this.value)\">\n";
echo "<option value=''>==== SELECT ====</option>\n";
$result=mysql_db_query($dbname,"select distinct(country) from addresses where detail='1'");
while(list($country)=mysql_fetch_array($result)){
echo "<option value=\"$country\">$country</option> \n" ;
}
} else if ($data=='amper') {
echo "<select name='amper' onChange=\"dochange('tumbon', this.value)\">\n";
echo "<option value=''>======== select ========</option>\n";
$val2=$val;
$val = substr($val,0,2);
$result=mysql_db_query($dbname,"SELECT distinct(state) FROM addresses WHERE detail='1' and country LIKE '$val%' ");
while(list($state)=mysql_fetch_array($result)){
echo "<option value=\"$state\" >$state</option> \n" ;
}
} else if ($data=='tumbon') {
echo "<select name='tumbon' >\n";
echo "<option value=''>======== select ========</option>\n";
$val2=$val;
$val = substr($val,0,4);
$result=mysql_db_query($dbname,"SELECT distinct(city) FROM addresses WHERE
detail='1' and state LIKE '$val%'");
while(list($city)=mysql_fetch_array($result)){
echo "<option value=\"$city\" >$city</option> \n" ;
}
}
echo "</select>\n";
?>