Query by date range This post was last written by u014474944 at 2014-04-0422: 38: 04 edit to view the data of yesterday after opening the webpage by default. enter the date you want to query in the text box and click query. the code I wrote is as follows $ mindate $ _ GET [mindate]. $ maxdate $ _ GET [maxdate]; $ SQL date range query
This post was last edited by u014474944 at 22:38:04 on
If you want to open the web page by default, you can view the data of yesterday.
You can also enter the date and time to query in the text box
The code I wrote is as follows:
$mindate=$_GET['mindate'];
$maxdate=$_GET['maxdate'];
$sql="SELECT * from `khxx` where $mindate and $maxdate";
There are two problems
1. The result is not directly queried based on the content of the text box.
2. because the value content is defined in the input, although the value in the text box is returned after the data is submitted by another date point.
------ Solution --------------------
Apparently, your SQL statement is wrong.
$mindate = isset($_GET['mindate'])?$_GET['mindate']:date("Y-m-d",strtotime("-1 day"));
$maxdate = isset($_GET['maxdate'])?$_GET['maxdate']:date("Y-m-d",strtotime("-1 day"));
------ Solution --------------------
$ SQL = "SELECT * from 'khxx' where $ mindate and $ maxdate"; problem.
If the date field of your database is addtime, write it like this
$ SQL = "SELECT * from 'khxx' where addtime> '". $ mindate. "' and addtime <'". $ maxdate ."'";