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

Recommended Answers

All 3 Replies

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";

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.