|
 |
|
สอบถาม ระบบจองห้องประชุม เรื่องเช็คค่าจองซ้ำ แล้วแสดง Popup ไม่ถูกต้อง |
|
 |
|
|
 |
 |
|
จะสอบถามว่า ทําไมเวลาจองซ้ำห้องเดียวกัน และเวลาเดียว ถึงยังแสดง Popup ว่า ห้องว่าง ทั้งๆๆที่เวลานั้นมีคนจองไปแล้วตามรูปและโค๊ดด้านล่างครับ

อันนี้โค็ดแสดง Popup ครับ
Code (PHP)
<?php
header("Content-type: text/html; charset=utf8");
header("Cache-Control: no-cache, must-revalidate");
require_once('connection.php');
require_once('function.php');
$room_id=$_GET['room_id'];
$s_time=$_GET['s_time'];
$datemeet=$_GET['datemeet'];
$datemeet=d2sql($datemeet);
$c_chkdup=mysql_db_query($dbname,"select subject,s_time,e_time from bookroom where datemeet='$datemeet' and s_time>='$s_time' and e_time>='$s_time' and room_id='$room_id' ");
if(mysql_num_rows($c_chkdup)>0) {
//$f_subj=mysql_fetch_array($c_chkdup);
echo "ห้องประชุมไม่ว่างมีการจัดประชุมเรื่อง : $f_subj[0] เวลา $f_subj[1]-$f_subj[2] ";
}
else echo "ห้องว่างสามารถจองได้ !";
?>
อันนี้โค็ด Function ครับ
Code (PHP)
<script language="javascript">
function checkdup(s_time,room_id,datemeet){
var url = "a_chkdup.php?s_time="+s_time+"&room_id="+room_id+"&datemeet="+datemeet ;
xmlhttp = newXmlHttp();
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
//document.getElementById('chkdup').innerHTML = xmlhttp.responseText ;
alert(xmlhttp.responseText);
}
</script>
อันนี้คําสั่งตรวจสอบห้อง
Code (PHP)
<input type="button" name="back2" value="ตรวจสอบห้อง" onClick="checkdup(this.value+':00',document.getElementById('room_id').value,document.getElementById('datemeet').value)" />
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2013-04-02 11:41:42 |
By :
ืnoom |
View :
1888 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง Echo mysql_num_rows($c_chkdup) ดูครับว่าได้ค่าเป็นอะไร
|
 |
 |
 |
 |
Date :
2013-04-02 11:56:28 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ให้ลองเพิ่มคำสั่งแสดง SQL ที่ใช้ดูนะครับ
Code (PHP)
echo "select subject,s_time,e_time from bookroom where datemeet='$datemeet' and s_time>='$s_time' and e_time>='$s_time' and room_id='$room_id' ";
แล้วก็เอาไปรันใน phpMyAdmin ดูครับว่าทำไมถึงไม่ได้ข้อมูลตามที่กำหนด
เพราะถ้ามีคนจองแล้ว จะต้องมีข้อมูลขึ้นมาแสดง
อาจจะเป็นชนิดข้อมูลของฟิลด์วันที่ และเวลาก็ได้ครับ
|
ประวัติการแก้ไข 2013-04-02 14:23:53
 |
 |
 |
 |
Date :
2013-04-02 14:23:06 |
By :
Naizan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|