|
 |
|
PHP PDO : รบกวนสอบถามการค้นหาระหว่างวันที่หน่อยครับ |
|
 |
|
|
 |
 |
|
รบกวนสอบถามการ SELECT BETWEEN ของ Field ของ DATE (DateTime) หน่อยครับ
ค้นหาแล้วไม่เจอข้อมูลเลยครับ ไม่แน่ใจเรื่อง DateTime Format ในรูปแบบ PDO ครับ
โครงสร้างข้อมูลครับ

ตัวอย่างข้อมูลครับ

โค้ดหน้าฟอร์มส่งข้อมูลครับ
Code (PHP)
<form class="user" name="form1" method="post" action="report_result.php">
<div class="form-group row mb-0">
<div class="col-sm-5 mb-sm-0">
<input type="text" class="form-control form-control-user" id="date_start" name="date_start" placeholder="Start Date">
</div>
<div class="col-sm-5">
<input type="text" class="form-control form-control-user" id="date_end" name="date_end" placeholder="End Date">
</div>
<div class="col-sm-2">
<button name="submit" id="submit" class="btn btn-primary btn-user btn-block" type="submit">Search</button>
</div>
</div>
</form>
โค้ดหน้าค้นหาข้อมูลครับ
Code (PHP)
ini_set('display_errors', 1);
error_reporting(~0);
//Location File
$dbFile = "report.mdb";
if (!file_exists($dbFile)) {
die("Could not find database file.");
}
//Connect
//Enable php.ini >extension=php_pdo.dll >extension=php_pdo_mysql.dll
$db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbFile; Uid=; Pwd=;");
// Get POST data
//$get_date_start = (!empty($_POST['date_start']) ? $_POST['date_start'] : '');
//$get_date_end = (!empty($_POST['date_end']) ? $_POST['date_end'] : '');
//$date_start = $get_date_start ." 00:00:00";
//$date_end = $get_date_end ." 00:00:00";
$get_date_start = "2019-06-06 00:00:00";
$get_date_end = "2019-06-06 00:00:00";
//$date_start = date('Y-m-d', strtotime($get_date_start));
//$date_end = date('Y-m-d', strtotime($get_date_end));
//Statment
//$stmt = $db->prepare("SELECT ID, DATE, TIME, JOB, CHONG FROM CALL");
$stmt = $db->prepare("SELECT ID, DATE , TIME, JOB, CHONG FROM CALL WHERE DATE BETWEEN :SearchS AND :SearchE");
$stmt->bindParam(':SearchS', $get_date_start, PDO::PARAM_STR);
$stmt->bindParam(':SearchE', $get_date_end, PDO::PARAM_STR);
$stmt->execute();
$stmt->debugDumpParams();
$result_call = $stmt->fetchAll(PDO::FETCH_ASSOC);
ขอบคุณครับ
Tag : PHP, Ms Access, XAMPP

|
ประวัติการแก้ไข 2019-07-07 20:25:42
|
 |
 |
 |
 |
Date :
2019-07-07 20:23:03 |
By :
pramuan_thaicreate |
View :
1153 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$stmt->execute() or die( json_encode($stmt->errorInfo()));
ลองดู ว่ามีอะไรบ้าง ประยุกต์ใช้เอา
|
 |
 |
 |
 |
Date :
2019-07-07 22:02:41 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|