Can you show the next available date from the database?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can you show the next available date from the database?

Post by simonmlewis »

This is related to a previous enquiry here.

We have a web site for racing cars, and it shows the Race Dates.

What we want to do is to show the date of the next Race Meeting, based on today's date.
ie. today is 19th August 2010.
There are 20 dates in the database going from 15th July 2010 through to 30 October 2010.

There might be a date of 25th August 2010 in there.

How do I make it pic out that date from all the others? I would have thought it's to do with converting the date to an str*, and then some maths. But am not quite sure how to go about this one.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Can you show the next available date from the database?

Post by requinix »

If you simply store the dates then a mere

Code: Select all

...WHERE datefield > "today's date"...
in your SQL should be enough.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can you show the next available date from the database?

Post by simonmlewis »

Ohhh, and in theory then you can order them by date, and LIMIT ? Like you do with Page Numbering?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply