pda4me
asked on
Dynamic Date select using PHP and MySQL
I have the following MySQL query in PHP:
How do I alter this code to use the EntryDate column to select from the past 7 days based on the current date this query is run?
$query = @mysql_query("SELECT * FROM RESI WHERE CITY='City1' OR CITY='City2' AND EntryDate='2006-04-10 00:00:00' ORDER BY EntryDate DESC LIMIT 0,10");
How do I alter this code to use the EntryDate column to select from the past 7 days based on the current date this query is run?
ASKER
blank results...are we missing a ' or something?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
FYI, EntryDate is a datetime field, not sure if that matters?
We cross-posted... Did you see my second suggestion?
ASKER
That is great, thanks for the help!
Glad to help :)
$query = @mysql_query("SELECT * FROM RESI WHERE CITY='City1' OR CITY='City2' AND EntryDate BETWEEN NOW() - 7 AND NOW() ORDER BY EntryDate DESC LIMIT 0,10");