This is a discussion on "MYSQL/PHP Query question" within the Databases section. This forum, and the thread "MYSQL/PHP Query question are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
MYSQL/PHP Query question
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
MYSQL/PHP Query question
I was wondering if anyone on here could help.....
I've been given the task of creating an index for our website at work based on some data in a database... Basically, it's product release date data, the thing is the data is in the following format: 2007-11-01 00:00:00 Some of the release dates are 2020-11-01 00:00:00 but this is too far in the future, what i need to do is have the query return stuff released in the next 30 days. The table is called P_products and the column with the release dates is called release_date. I know it's cheeky but would somebody please be able to help me out with an example? I'm using PHP so i guess i'll need to set a variable with the current date in it? Thanks |
|
|
|
#2
|
|||
|
|||
|
Re: MYSQL/PHP Query question
give this a go:
$today = date('Y-m-d', strtotime('now')); $oneMonthAway = date('Y-m-d', strtotime('+1 month')); $query = "SELECT * FROM posts WHERE release_date BETWEEN '$today' AND '$oneMonthAway' ORDER BY release_date DESC" do you see what's happening? if not, post again |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Mysql Query not working | nate2099 | Databases | 13 | Jan 3rd, 2008 02:28 |
| MYSQL PHP query class | jhappeal | Databases | 1 | Aug 17th, 2007 01:52 |
| MySQL query query | dangergeek | Databases | 3 | Apr 12th, 2007 12:45 |
| Returning a value from a MYSQL Query? | Kimochi | PHP Forum | 7 | Feb 28th, 2007 20:09 |
| mysql query in a function | Redempt1on | PHP Forum | 6 | May 19th, 2006 01:25 |