|
 |
|
ช่วยอธิบายโค้ดนี้ให้หน่อยนะครับ ว่าตัวไหนทำงานอะไร |
|
 |
|
|
 |
 |
|
ช่วยอธิบายโค้ดนี้ให้หน่อยนะครับ ตั้งแต่บรรทัดแรกเลยอะครับ
Code (PHP)
$check_date = "";
foreach($_POST["date1"] as $key=>$val){
$stime = $_POST["hour1"][$key].':'. $_POST["min1"][$key];
$etime = $_POST["hour2"][$key].':'. $_POST["min2"][$key];
$room=$_POST['txtroom'];
$strSQL = "SELECT * FROM booking WHERE r_id = '".$room."'
AND ((sdate='".$val."')) AND (('".$stime."' BETWEEN stime AND etime) OR ('".$etime."' BETWEEN stime AND etime )OR (stime between '".$stime."' and '".$etime."') OR (etime between '".$stime."' and '".$etime."'))";
$objQuery = mysql_query($strSQL) or die(mysql_error());
$objResult = mysql_fetch_array($objQuery);
if($objResult['sdate']){
$check_date.= $objResult['sdate']. ' เวลา '. $stime .' - '. $etime;
}
}
if($check_date != "")
{
echo "<script>alert('ห้องนี้วันที่ $check_date มีผู้ใช้งานแล้ว');history.back();</script>";
}
else{
$m_id=$_POST['txtm_id'];
$name=$_POST['txtname'];
$sex=$_POST['txtsex'];
$org=$_POST['txtorg'];
$tel=$_POST['txttel'];
$fax=$_POST['txtfax'];
$mail=$_POST['txtmail'];
$sql="INSERT INTO `bkkbooking`.`member` (`name` ,`sex` ,`organ` ,`tel` ,`fax` ,`email` ,`type` )
VALUES ('".$name."', '".$sex."', '".$org."', '".$tel."', '".$fax."', '".$mail."', '0')";
$result = mysql_query($sql) or die(mysql_error());
$id=mysql_insert_id();
if($sql){
foreach($_POST["date1"] as $key=>$val){
$startTime = $_POST["hour1"][$key].':'. $_POST["min1"][$key];
$stopTime = $_POST["hour2"][$key].':'. $_POST["min2"][$key];
$room=$_POST["txtroom"];
$detail=$_POST["txtdetail"];
$sql_insert = " INSERT INTO `bkkbooking`.`booking` (`m_id` ,`appdate` ,`sdate` ,`edate` ,`stime` ,`etime` ,`r_id` ,`detail` ,`status` )";
$sql_insert.= " VALUES('".$id."','".date("Y-m-d")."','".$val."','".$val."', '".$startTime."','".$stopTime."','".$room."','".$detail."','0'); ";
$objQuery = mysql_query($sql_insert) or die(mysql_error());
}
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2013-07-17 10:55:07 |
By :
psist |
View :
616 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เข้าไปอ่านบทความ PHP กับ MySQL ครับ
|
 |
 |
 |
 |
Date :
2013-07-17 14:04:55 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|