|
 |
|
ใครก้อได้ช่วยดูโค้ดให้ผมหน่อยครับ ติดเงื่อนไข ไม่ยอมออกครับ |
|
 |
|
|
 |
 |
|
เกี่ยวกับการจองห้องครับ มี 3 ช่วงเวลา 1=เช้า 2=บ่าย 3=ทั้งวัน
ที่ต้องการคือ
จอง 3 2กับ1 จองไม่ได้
จอง 2กับ 3จองไม่ได้
แต่ตอนนี้จอง 1 ได้ แแล้ว 2 ไม่ได้ ประมาณว่าในวันที่จองนั้นจะจองไม่ได้
*** เงื่อนไขคือ ห้อง วันที่ ซ้ำกับได้ แต่ช่วงเวลาตามที่บอกครับ ***
ไงๆก้อช่วยแนาะนำหน่อยครับ หรือจาบอกตรงๆ เลยก้อได้ครับ
Code (PHP)
<?php
$con = mysql_connect("localhost","root","1234");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error());
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error());
$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
$rr="$_POST[roomddl]";
$uu="$_POST[txtdate]";
$timeSts="$_POST[timedll]";
//$timeSts="$_POST[timeSts]"; // สถานะ ช่วงเวลาในการจอง เช่น 1 เช้า 2 บ่าย 3 ทั้งวัน
$select="SELECT * FROM tbres WHERE room='$rr' AND use_date='$uu'";
$result=mysql_query($select);
$row=mysql_fetch_array($result);
$num=mysql_num_rows($result);
if($num >0 ){
$sts= $row["time_res"];
echo "$sts";
if($sts==3){
echo "<script>alert('ไม่สามารถงจองห้องได้ในวันนี้ กรุณากลับไปแก้ไข');window.location='index.php';</script>";exit();}
if($sts==$timeSts){
echo "<script>alert('ไม่สามารถงจองห้องได้ในช่วงเวลานี้ กรุณากลับไปแก้ไข');window.location='index.php';</script>";exit();}
} else{
$sql="INSERT INTO tbres (room,log_date, use_date, time_res,res_ing,unit)VALUES('$_POST[roomddl]',CURDATE(),'$_POST[txtdate]','$_POST[timedll]','$_POST[namerestxt]','$_POST[txtunit]')";
if (!mysql_query($sql,$con)) {
echo "<script>alert('ไม่สามารถเพิ่มข้อมูลได้');window.location='index.php';</script>";exit();
}
echo "<script>alert('คุณได้ทำการเพิ่มข้อมูลได้');window.location='index.php';</script>";exit();
}
mysql_close($con)
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-09-22 15:36:29 |
By :
oasiis |
View :
939 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่าลอง
if ($sts==3) { ไม่สามารถเลือกได้แล้ว }
else if ($sts==2 and $timeSts = 3) { ไม่สามารถเลือกได้แล้ว }
else {
จองได้
}
ไม่รู้ว่าถูกหรือ่ปาวนะ
|
 |
 |
 |
 |
Date :
2009-09-23 10:04:12 |
By :
taobsd |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|