Date range query-php Tutorial

Source: Internet
Author: User
To query the date range, you can view the data of yesterday after you open the webpage by default.
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.


Reply to discussion (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 "));

$ 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 ."'";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.