|
|
|
จองห้องพักข้ามเดือนคำนวนออกมาติดลบ จะเขียนแบบใหนดีคะให้คลอบคลุมการทำงาน |
|
|
|
|
|
|
|
ถ้าผมจำไม่ผิด มันมีอยู่นะครับ แปลง datetime เป็น วินาที แล้วเอาไป - กับวันจอง
แล้วค่อย แปลงกลับมาเป็น datetime อีกครั้ง ลองค้นในนี้ดูครับ
ถ้าหาเจอเดี๋ยวเอามาฝากครับ
|
|
|
|
|
Date :
2012-02-16 13:23:55 |
By :
13eachz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ๋อ มันผิดที่บรรทัด 20 ตัวอักษรที่ 10 (ล้อเล่นนะ)
ถามสั้นๆแบบนี้ ใครจะบอกได้ครับ
|
ประวัติการแก้ไข 2012-02-16 13:24:29
|
|
|
|
Date :
2012-02-16 13:24:12 |
By :
randOmizE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อันนี้คือโค๊ดที่ผิดอะคะที่บอกไว้ในตอนแรกมันคำนวนผิดอะคะ
Code (PHP)
<script language ="javaScript">
function goHist(a)
{ history.go(a);}
</script>
<?php
//session_start() ;
if(!session_is_registered("login_true")) {
echo "<meta http-equiv='refresh' content='0;url=index.php'>" ;
exit() ;
}
include("config.php") ;
mysql_select_db($dbname) ;
$AMem_ID = $_POST["AMem_ID"];
$Staff_ID = $_POST["Staff_ID"];
$bookType = $_POST["bookType"];
$checkin = $_POST["checkin"];
$checkout = $_POST["checkout"];
//$room = $_POST["room"];
$result1 = mysql_query("select * from staff where Staff_ID='$Staff_ID'") or die ("Err Can not to result") ;
$dbarr1 = mysql_fetch_array($result1) ;
$Staff_User = $dbarr1["Staff_User"];
$result = mysql_query("select * from member where Mem_ID='$AMem_ID'") or die ("Err Can not to result") ;
$dbarr = mysql_fetch_array($result) ;
$Mem_ID = $dbarr["Mem_ID"];
$nDate = Date("Y-m-d");
$startD = explode("/",$checkin);
$endD = explode("/",$checkout);
if($endD[2] > $startD[2] )
{
if($startD[1] == 12 && $endD[1] == 1 )
{
$sday = 31- $startD[0] ;
$eday = $endD[0] ;
$Rns = $sday + $eday ;
}
else if($startD[1] == 11 && $endD[1] == 1)
{
$sday = 30- $startD[0] ;
$eday = $endD[0] ;
$nday = 31;
$Rns = $sday + $eday + $nday;
}
else if($startD[1] == 10 && $endD[1] == 1)
{
$sday = 31- $startD[0] ;
$eday = $endD[0] ;
$nday = 30;
$nday1 = 31;
$Rns = $sday + $eday + $nday + $nday1 ;
}
else
{ echo"Error"; exit();}
}
else // ปีเดียวกัน
{
if($startD[1] == 1)
$sday = 31;
else if($startD[1] == 2)
$sday = 28;
else if($startD[1] == 3)
$sday = 31;
else if($startD[1] == 4)
$sday = 30;
else if($startD[1] == 5)
$sday = 31;
else if($startD[1] == 6)
$sday = 30;
else if($startD[1] == 7)
$sday = 31;
else if($startD[1] == 8)
$sday = 31;
else if($startD[1] == 9)
$sday = 30;
else if($startD[1] == 10)
$sday = 31;
else if($startD[1] == 11)
$sday = 30;
else
$sday = 31;
$day1 = $sday - $startD[0] ;
if($endD[1] == $startD[1])
{
$Rns = $endD[0]-$startD[0] ;
}
else if($endD[1] - $startD[1] == 2)
{
$nextM = $startD[1] +1;
if($nextM[1] == 1)
$sday = 31;
else if($nextM[1] == 2)
$sday = 28;
else if($nextM[1] == 3)
$sday = 31;
else if($nextM[1] == 4)
$sday = 30;
else if($nextM[1] == 5)
$sday = 31;
else if($nextM[1] == 6)
$sday = 30;
else if($nextM[1] == 7)
$sday = 31;
else if($nextM[1] == 8)
$sday = 31;
else if($nextM[1] == 9)
$sday = 30;
else if($nextM[1] == 10)
$sday = 31;
else if($nextM[1] == 11)
$sday = 30;
else
$sday = 31;
$Rns = $day1+$endD[0] +$sday ;
}
else if($endD[1] - $startD[1] == 3)
{
$nextM = $startD[1] +1;
$nextM1 = $startD[1] +2;
if($nextM[1] == 1)
$sday = 31;
else if($nextM[1] == 2)
$sday = 28;
else if($nextM[1] == 3)
$sday = 31;
else if($nextM[1] == 4)
$sday = 30;
else if($nextM[1] == 5)
$sday = 31;
else if($nextM[1] == 6)
$sday = 30;
else if($nextM[1] == 7)
$sday = 31;
else if($nextM[1] == 8)
$sday = 31;
else if($nextM[1] == 9)
$sday = 30;
else if($nextM[1] == 10)
$sday = 31;
else if($nextM[1] == 11)
$sday = 30;
else
$sday = 31;
if($nextM1[1] == 1)
$sday1 = 31;
else if($nextM1[1] == 2)
$sday1 = 28;
else if($nextM1[1] == 3)
$sday1 = 31;
else if($nextM1[1] == 4)
$sday1 = 30;
else if($nextM1[1] == 5)
$sday1 = 31;
else if($nextM[1] == 6)
$sday = 30;
else if($nextM1[1] == 7)
$sday1 = 31;
else if($nextM1[1] == 8)
$sday1 = 31;
else if($nextM1[1] == 9)
$sday1 = 30;
else if($nextM1[1] == 10)
$sday1 = 31;
else if($nextM1[1] == 11)
$sday1= 30;
else
$sday1 = 31;
$Rns = $day1+$endD[0] +$sday+$sday1 ;
}
else
{ echo"Error"; exit();}
}
//echo"Rns = $Rns"; exit();
$chkinD = explode("/",$checkin);
$ChkDate = "$chkinD[2]-$chkinD[1]-$chkinD[0]";
$chkoutD = explode("/",$checkout);
$Chk_ODate = "$chkoutD[2]-$chkoutD[1]-$chkoutD[0]";
//echo"$ChkDate";exit();
if( $AMem_ID =="")
{
$sql1 = "insert into reserve (Res_ID,Res_Date,Resort_ID,Res_CheckIn,Res_CheckOut,Res_NumRoom,Mem_ID,Staff_ID,Res_status) values('0','$nDate','$bookType','$ChkDate','$Chk_ODate','$Rns','$Mem_ID','$Staff_ID','2')";
$result2 = mysql_db_query($dbname, $sql1);
$sql2 = "update resort set Sta_ID ='3' where Resort_ID = '$bookType' ";
$dbquery = mysql_db_query($dbname,$sql2);
}
else
{
$sql1 = "insert into reserve (Res_ID,Res_Date,Resort_ID,Res_CheckIn,Res_CheckOut,Res_NumRoom,Mem_ID,Staff_ID,Res_status) values('0','$nDate','$bookType','$ChkDate','$Chk_ODate','$Rns','$Mem_ID','$Staff_ID','1')";
$result2 = mysql_db_query($dbname, $sql1);
$sql2 = "update resort set Sta_ID ='2' where Resort_ID = '$bookType' ";
$dbquery = mysql_db_query($dbname,$sql2);
}
if (!$result2)
{ echo("เอ็กซิคิวต์คำสั่ง SQL ไม่ได้ " . mysql_error() ); exit; }
else
{
echo "<font size=3>บันทึกข้อมูลเรียบร้อยแล้ว <br>";
header("location:SReport.php?&login_true=$Staff_User");
// echo"top.location='booking.php' ";
}
?>
|
|
|
|
|
Date :
2012-02-16 13:32:17 |
By :
konsand |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|