<? session_start(); if($_SESSION['Username'] == "") { echo "Please Login!"; exit(); } if($_SESSION['Status'] != "ADMIN") { echo "This page for Admin only!"; exit(); } include "connect.php"; $strSQL = "SELECT * FROM member WHERE UserID = '".$_SESSION['UserID']."' "; mysql_query("SET NAMES TIS620"); $objQuery = mysql_query($strSQL); $objResult = mysql_fetch_array($objQuery); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-874" /> <title>รายงานการคืนหนังสือ</title> <link rel="stylesheet" type="text/css" href="css/style.css" /></head> <body> <table width="1024" border="0" align="center" cellspacing="0"> <tr> <td><img src="images/head.jpg"></td> </tr> <tr> <td align="right"><a href="index.php">หน้าหลัก</a> | <a href="add-book.php">จัดการหนังสือ</a> | <a href="add-category.php">จัดการหมวดหมู่</a> | <a href="add-user.php">จัดการสมาชิก</a> | <a href="add-new.php">จัดการข่าวประชาสัมพันธ์</a> | <a href="borrow.php">ยืมหนังสือ</a> | <a href="return.php">คืนหนังสือ</a> | <a href="report-borrow-by-date.php">รายงานการยืม</a> | <a href="report-return-by-date.php">รายงานการคืน+ค่าปรับ</a> | <a href="report-no-return.php">รายงานการค้าง</a> | <a href="statistic.php">สถิติการยืม</a> | <a href="../logout.php">ออกจากระบบ</a></td> </tr> <tr> <td align="center" valign="top"><p> <? include "connect.php"; $strSQL = "SELECT * FROM book Where date_b != '' order by IDBook DESC"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $date_now = date('d-m-Y'); ?> <p> </p> <p> </p> <table width="545" align="center"> <tr> <td width="537" align="center"><strong><font size="3">ตรวจสอบสถานะการจอง</font></strong></td> </tr> </table> <p> </p> <table width="700" border="0" align="center"> <tr> <td><form id="form1" name="form1" method="post" action="check-status2.php"> <table class="simply" width="710" align="center"> <thead> <tr> <th width="136" align="center">เลขทะเบียน</th> <th width="138" align="center">วันที่จอง</th> <th width="134" align="center">วันที่ปัจจุบัน</th> <th width="134" align="center">คิดเป็น</th> <th width="134" align="center">อัพเดท</th> </tr> </thead> <? $Num_Rows=mysql_num_rows($objQuery); if($Num_Rows==0){ ?> <tr bgcolor="#FFFF99"> <td align="center">ไม่มีข้อมูล</td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> </tr> <? }else $i = 1; if($Page > 1) { $i = ($Per_Page * ($Page-1)) + 1; } while($objResult = mysql_fetch_array($objQuery)) { ?> <tbody> <tr> <td align="center" valign="top"><?=$objResult["IDBook"];?></td> <td align="center" valign="top"><?=$objResult["date_b"];?></td> <td align="center" valign="top"><?=$date_now;?></td> <td align="center" valign="top"> <? function DateDiff($strDate1,$strDate2) { return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24 } include "connect.php"; $strSQL = "SELECT * FROM book "; mysql_query("SET NAMES TIS620"); $objQuery = mysql_query($strSQL); $objResult = mysql_fetch_array($objQuery); $d1 = $objResult["date_b"]; $d2 = date('d-m-Y'); $check_d = DateDiff("$d1","$d2") ; //เช็คว่า วันแรก กับ วันสุดท้าย ห่างกันกี่วัน if($check_d >2) { echo"$check_d"; } else { } ?> </td> <td align="center" valign="top"><label> <input type="submit" name="button" id="button" value="เปลี่ยนสถานะ" /> </label></td> </tr> <? $i++; } ?> </tbody> </table> </form> </td> </tr> </table></td> </tr> </table> </body> </html>
Quote:include "connect.php";
function DateDiff($strDate1,$strDate2) { return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24 }
<? session_start(); mysql_connect("localhost","root","1234"); mysql_select_db("test"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>รายงานการคืนหนังสือ</title> <?php date_default_timezone_set('UTC'); $date_now = date('d-m-Y'); echo $date_now."<br>"; $sql = "select * from booking order by booking_id"; $rs = mysql_query($sql); while($row = mysql_fetch_object($rs)) { $date_db = date("d-m-Y" , strtotime($row->date_booking)); // แปลง ให้อยู่ในรูปแบบเดียวกัน echo $date_db."<br>"; echo (( strtotime($date_now) - strtotime($date_db) ) / ( 60 * 60 * 24 ))."<br>"; // หาความต่างของวัน } ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง