 |
|
โค้ดเต็มครับ จะมี else ที่บรรทัด 170 ด้วยครับCode (PHP)
<?php
$options = $_GET['options'];
session_start() ;
include("config.inc.php") ;
?>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>ระบบค้นหาหอพัก</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
body {margin-right:0px;margin-left: 0px;margin-top:0px;margin-bottom:0px;}
#map_canvas {
width:400px;
height:400px;
margin:auto;
margin-top:20px;
}
</style>
<script language="javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript">
$(function(){
function drag_me(name){
$(name).css({
position:"absolute",
cursor:"move"
});
$(name).mousedown(function(event){
var locateX=event.pageX;
var locateY=event.pageY;
var obj_locateX=$(this).offset().left;
var obj_locateY=$(this).offset().top;
var diff_x=locateX-obj_locateX;
var diff_y=locateY-obj_locateY;
$(this).css("opacity",0.3).mousemove(function(event){
locateX=event.pageX;
locateY=event.pageY;
obj_locateX=$(this).offset().left;
obj_locateY=$(this).offset().top;
new_locateX=locateX-diff_x;;
new_locateY=locateY-diff_y;
$(this).css({
left:new_locateX,
top:new_locateY
}).bind("mouseup mouseout",function(){
$(this).css("opacity",1);
$(this).unbind("mousemove");
});
});
});
}
// การใช้งาน กำหนด selector วัตถุที่ต้องการ
// ในตัวอย่างคือ div ที่มี id เท่ากับ myblock
drag_me("div#myblock");
});
</script>
<style type="text/css">
<!--
.style13 {font-size: small}
.text1 { color: #666;
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
}
.style15 {
font-size: medium;
font-weight: bold;
}
-->
#map_canvas {
width:600px;
height:600px;
margin:auto;
margin-top:10px;
}
.style19 {color: #000000}
</style>
</head>
<body onLoad="pageLoad();">
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tbody><tr>
<td align="center" valign="top"><table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><? include 'logo.php'; ?> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><? include 'menu.php'; ?></td>
</tr>
</table>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" bgcolor="#FFFFFF"><center><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" align="left" valign="top"> </td>
<td width="44%" align="left" valign="top"><table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><? switch($options)
{
default:
{
?></td>
</tr>
</table>
<div>
<b class="spiffy">
<b class="spiffy1"><b></b></b>
<b class="spiffy2"><b></b></b>
<b class="spiffy3"></b>
<b class="spiffy4"></b>
<b class="spiffy5"></b></b>
<div class="spiffyfg">
<center> <table width="98%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td><span class="style15">แสดงรายการค้นหา</span></td>
</tr>
<tr>
<td><p class="CurPage style13"> </p> </td>
<td><p class="CurPage style13">
<?
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
$c2 = $_POST['c2'];
if($c or $b){
$query=mysql_query("SELECT * FROM tbldorm where dorm_price >= '$c' or dorm_rent = '$b' ");
}
else if($a or $c2){
$query=mysql_query("SELECT * FROM tbldorm where dorm_dormitory = '$a' or dorm_price <= '$c2' ");
}
$num = mysql_num_rows($query);
if($num > 0 ) {
while($objResult = mysql_fetch_array($query))
{
?>
<br />
</p>
<center>
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="47%" bgcolor="#66CC33"><div align="center" class="style19 style13 style10 style11">
<div align="left"><strong>ชื่อหอพัก</strong></div>
</div></td>
<td width="53%" bgcolor="#66CC33"><div align="center" class="style13 style19 style11">
<div align="left"><strong>รายละเอียด</strong></div>
</div></td>
</tr>
<tr onMouseOver="this.className='menu-over'" onMouseOut="this.className='menu'" class="menu">
<td valign="top"><div align="center" class="style13">
<div align="left"><span class="link style10"><? echo $objResult['dorm_name']; ?></span><br>
<br>
<a href="dorm_detail.php?id=<? echo $objResult['dorm_id']; ?>"><img src="img/icon_detail.th.gif" width="61" height="15" border="0"></a></div>
</div></td>
<td valign="top"><div align="left"><span class="link style10 style13"><? echo $objResult['dorm_about']; ?><br>
<br>
ระยะห่างจากมหาวิทยาลัย <? echo $objResult['dorm_km']; ?> Km.</span></div></td>
</tr>
</table>
<p class="CurPage style13"><br />
<span class="link">
<?
} } else
{
?> ไม่พบข้อมูล <? } ?>
</span></p>
<p class="CurPage style13"> </p>
</td>
</tr>
</table>
</div>
<b class="spiffy">
<b class="spiffy5"></b>
<b class="spiffy4"></b>
<b class="spiffy3"></b>
<b class="spiffy2"><b></b></b>
<b class="spiffy1"><b></b></b></b>
</div>
</td>
<td width="55%" valign="top"> <div id="map_canvas"></div>
<script type="text/javascript">
var map; // กำหนดตัวแปร map ไว้ด้านนอกฟังก์ชัน เพื่อให้สามารถเรียกใช้งาน จากส่วนอื่นได้
var GGM; // กำหนดตัวแปร GGM ไว้เก็บ google.maps Object จะได้เรียกใช้งานได้ง่ายขึ้น
function initialize() { // ฟังก์ชันแสดงแผนที่
GGM=new Object(google.maps); // เก็บตัวแปร google.maps Object ไว้ในตัวแปร GGM
// กำหนดจุดเริ่มต้นของแผนที่
var my_Latlng = new GGM.LatLng(14.85467,103.48357);
// กำหนด DOM object ที่จะเอาแผนที่ไปแสดง ที่นี้คือ div id=map_canvas
var my_DivObj=$("#map_canvas")[0];
// กำหนด Option ของแผนที่
var myOptions = {
zoom: 14, // กำหนดขนาดการ zoom
center: my_Latlng , // กำหนดจุดกึ่งกลาง
mapTypeId:GGM.MapTypeId.ROADMAP, // กำหนดรูปแบบแผนที่
mapTypeControlOptions:{ // การจัดรูปแบบส่วนควบคุมประเภทแผนที่
position:GGM.ControlPosition.TOP, // จัดตำแหน่ง
style:GGM.MapTypeControlStyle.DROPDOWN_MENU // จัดรูปแบบ style
}
};
map = new GGM.Map(my_DivObj,myOptions);// สร้างแผนที่และเก็บตัวแปรไว้ในชื่อ map
$.ajax({
url:"getsearch_dorm3.php?a=<? echo $a; ?>&b=<? echo $b; ?>&c=<? echo $c; ?>", // ใช้ ajax ใน jQuery เรียกใช้ไฟล์ xml
dataType: "xml",
success:function(xml){
$(xml).find('marker').each(function(){ // วนลูปดึงค่าข้อมูลมาสร้าง marker
var markerID=$(this).attr("id");// นำค่าต่างๆ มาเก็บไว้ในตัวแปรไว้ใช้งาน
var markerName=$(this).find("name").text(); // นำค่าต่างๆ มาเก็บไว้ในตัวแปรไว้ใช้งาน
var markerLat=$(this).find("latitude").text(); // นำค่าต่างๆ มาเก็บไว้ในตัวแปรไว้ใช้งาน
var markerLng=$(this).find("longitude").text(); // นำค่าต่างๆ มาเก็บไว้ในตัวแปรไว้ใช้งาน
var markerLatLng=new GGM.LatLng(markerLat,markerLng);
var my_Marker = new GGM.Marker({ // สร้างตัว marker
position:markerLatLng, // กำหนดไว้ที่เดียวกับจุดกึ่งกลาง
map: map, // กำหนดว่า marker นี้ใช้กับแผนที่ชื่อ instance ว่า map
title:markerName // แสดง title เมื่อเอาเมาส์มาอยู่เหนือ
});
// console.log($(this).find("id").text());
});
}
});
}
$(function(){
$("<script/>", {
"type": "text/javascript",
src: "http://maps.google.com/maps/api/js?v=3.2&sensor=false&language=th&callback=initialize"
}).appendTo("body");
});
</script></td>
</tr>
</table>
<p><br>
</p>
<center><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<br></td>
</tr>
</table>
<p> </p>
<p> </p>
<p>
<?
}
break;
}
?>
</p>
<p> </p>
<p> </p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><? include 'foorter.php'; ?></td>
</tr>
</table> <p> </p></td>
</tr>
</table></td>
</tr>
</tbody></table>
</div>
</body></html>
|
 |
 |
 |
 |
Date :
2011-11-16 12:53:38 |
By :
buraratn |
|
 |
 |
 |
 |
|
|
 |