MYSQL/PHP Query question

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 19th, 2007, 10:37
Junior Member
Join Date: May 2006
Location: London
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to andrewlondon
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
Reply With Quote

  #2 (permalink)  
Old Sep 19th, 2007, 11:26
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 05:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43