0

Hi, i have made a form in which people fill out their details and its gets saved in database with

$today = date("F j, Y");

now i want to make a search for that forms with date , like Search with in last 3 days or Last 6 months. so when somebody do that, search will show all the forms submitted in last 3 days only or 6 months. respectively. please if somebody can write a code or example for that, instead of just telling me to use some function with just referring function's name.am just a amature in this.

Thank you in Advance

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Sahilsahni
0

First off,

$sevendaysago = date("Y-m-d", mktime (0,0,0,date("m"),(date("d")-7),date("Y")));   // 2010-11-13

$tomorrow = date("Y-m-d", mktime (0,0,0,date("m"),(date("d")+1),date("Y")));  // 2010-11-21

i am using the following query, assumming that the dateformat is the same as the above variables.

$query = "SELECT * FROM table WHERE date BETWEEN '$sevendaysago' AND '$tomorrow'  ORDER BY date ASC";

Edited by Frankey: n/a

0

First off,

$sevendaysago = date("Y-m-d", mktime (0,0,0,date("m"),(date("d")-7),date("Y")));   // 2010-11-13

$tomorrow = date("Y-m-d", mktime (0,0,0,date("m"),(date("d")+1),date("Y")));  // 2010-11-21

i am using the following query, assumming that the dateformat is the same as the above variables.

$query = "SELECT * FROM table WHERE date BETWEEN '$sevendaysago' AND '$tomorrow'  ORDER BY date ASC";

It worked, thanks Frankey. thanks a ton

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.