|
|
|
ต้องการค้นหาโรงแรมจาก จังหวัด-อำเภอ ด้วย AJAX ไฟล์ที่กะลังทามอยุ่ ต้องการให้แสดง รูปภาพ ชื่อ รายละเอียดของโรงแรมค่ะ |
|
|
|
|
|
|
|
ไฟล์ที่กะลังทามอยุ่ ต้องการให้แสดง รูปภาพ ชื่อ รายละเอียดของโรงแรมค่ะ ช่วยหน่อยน่ะค่ะ
Code (PHP)
<?php
$hostname_edoc = "127.0.0.1";
$database_edoc = "db_hotel";
$username_edoc = "root";
$password_edoc = "root";
$connect_db= mysql_pconnect($hostname_edoc, $username_edoc, $password_edoc) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
mysql_query("collation_connection = tis620_thai_ci");
mysql_query("collation_database = tis620_thai_ci");
mysql_query("collation_server = tis620_thai_ci");
mysql_select_db($database_edoc, $connect_db) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ค้นหาโรงแรมจาก จังหวัด-อำเภอ ด้วย AJAX</title>
<meta http-equiv="Content-Type" content="text/html; charset=TIS-620" />
<style type="text/css">
* {
font-family:Tahoma;
font-size:8pt;
}
.style1 {
font-size: 12pt;
font-weight: bold;
}
.style2 {font-size: 10pt}
</style>
<script language="javascript">
function go(which) {
n = which.value;
document.form1.submit() ;
}
</script>
</head>
<body>
<?
//ค่าที่ได้รับมาจากการ Submit
$province = $_POST[province];
$amphur = $_POST[amphur];
?>
<p align="center" class="style1">ค้นหาโรงแรม
<form id="form1" name="form1" method="post" action="index.php">
<table width="237" height="88" border="1" align="center" bordercolor="#0000FF" bgcolor="#66FFCC">
<tr>
<td width="60"><span class="style2">จังหวัด : </span></td>
<td width="146"><select name="province_id" id="province_id" onchange="go(this)" >
>
<?php
##############################################################
$query_type2 = "SELECT * FROM province where id='$province_id' ";
$type_db2 = mysql_query($query_type2, $connect_db) or die(mysql_error());
$row_province_id2 = mysql_fetch_assoc($type_db2);
################################################################ ?>
<option value="<?php echo $row_province_id2['id']?>" ><?php echo $row_province_id2['name']?></option>
<?
$sql_province = "SELECT * FROM province ";
$query_province = mysql_query($sql_province, $connect_db) or die(mysql_error());
$row_province_id = mysql_fetch_array($query_province) ;
do {
?>
<option value="<?php echo $row_province_id['id']?>" ><?php echo $row_province_id['name']?></option>
<?php
} while ($row_province_id = mysql_fetch_assoc($query_province));
?>
</select></td>
</tr>
<tr>
<td><span class="style2">อำเภอ : </span></td>
<td><select name="amphur_id" id="amphur_id" >
<?
$sql_amphur = "SELECT * FROM amphur where provinceID='$province_id' ";
$query_amphur = mysql_query($sql_amphur, $connect_db) or die(mysql_error());
$row_amphur_id = mysql_fetch_array($query_amphur) ;
do { ?>
<option value="<?php echo $row_amphur_id['id']?>" ><?php echo $row_amphur_id['name']?></option>
<?php
} while ($row_amphur_id = mysql_fetch_assoc($query_amphur));
?>
</select></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
//อาจจาผิดตรงส่วนนี้ ช่วยดูให้หน่อยน่ะ
<?php
if($Submit=="Submit"){
$sql_amphur = "SELECT
amphur.provinceID,
hotel.name as hotel_name ,
hotel.detail,
hotel.photo,
hotel.id_hotel,
province.name as province_name,
amphur.name as amphur_name ,
FROM
amphur
Inner Join tumbon ON amphur.id = tumbon.amphurID AND amphur.id = tumbon.amphurID
Inner Join province ON province.id = amphur.provinceID
Inner Join hotel ON tumbon.id = hotel.id_amphur
where tumbon.amphurID='$amphur_id'
";
$query_amphur = mysql_query($sql_amphur, $connect_db) or die(mysql_error());
$row_amphur_id = mysql_fetch_array($query_amphur) ;
?>
<table width="423" border="1" align="center" bordercolor="#0000FF" bgcolor="#CCFFCC">
<tr bgcolor="#0099FF">
<td width="163"><span class="style2">รูป</span></td>
<td width="244"><span class="style2">ชื่อ</span></td>
<td width="244"><span class="style2">รายละเอียด</span></td>
</tr>
<tr>
<td><?php print $row_amphur_id['photo']; ?></td>
<td><?php print $row_amphur_id['hotel_name']; ?></td>
<td><?php print $row_amphur_id['detail']; ?></td>
</tr>
</table>
<p>
<br>
<? } while ($row_amphur_id = mysql_fetch_assoc($query_amphur));
?></p>
</body>
</html>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-09-23 03:38:37 |
By :
ann |
View :
1059 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2009-09-23 09:38:15 |
By :
taobsd |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|