简体   繁体   中英

how to get results from a mysql database using three parameters like (date from, date to and an input field ) in PHP

i want to retrieve data from mysql database table based on three input search parameters like date from , date to , and input text field like location , customer id . Please provide some code how to do this?

Screen shot of table:

在此处输入图片说明

Suppose you've stored the input prams in following variables...

$date_from
$date_to
$location
$customer_id

and you have a table called customers, structured

id name email location date_from date_to

...you could then build your query like this:

"SELECT * FROM customers where id = $customer_id AND location = '$location' AND date_from = $date_from AND date_to = $date_to";

PS: I had images disabled on my browser so I couldn't see the screenshot you posted, instead I just generated a table structure as an example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM