0
我從Datepicker Jquery UI獲取DATE變量,並將其作爲變量包含在MYSQL語句中。但select不適用於該變量。什麼原因 ?在MYSQL數據庫中連接PHP變量DATETIME
下面的代碼
$fromDate = new DateTime($from);
$toDate = new DateTime($to);
$fromDate2 = mysqli_real_escape_string($fromDate);
$toDate2 = mysqli_real_escape_string($toDate);
$sql = mysqli_query($mySqlConnect,"SELECT * FROM 1398_log WHERE date BETWEEN $fromDate2 AND $toDate2 ORDER by id DESC");
此選擇確定:
$sql = mysqli_query($mySqlConnect,"SELECT * FROM 1398_log WHERE date BETWEEN '2016-03-01 00:00:00' AND '2016-06-30 23:59:59'ORDER by id DESC");