Jump to content

Issue with PHP and dates


mongoose0031800

Recommended Posts

Hello again!

 

How would I go about displaying data from a database query but only showing the results that have a date (in the date field in the db) the is either equal to the current date or in the future? Not show any results in which the date field has a date which is in the past?

 

Thanks!

 

Mongoose

Link to comment
https://forums.phpfreaks.com/topic/244549-issue-with-php-and-dates/
Share on other sites

One thing that may complicate this a little is I am already ordering the query by a field called position which is an integer. Here is my query:

 

$get_shows = mysql_query("SELECT * FROM shows WHERE front_page_featured = '1' ORDER BY position ASC");

You could also use the mysql built in date function to do it as well.

 

$get_shows = mysql_query("SELECT * FROM shows WHERE front_page_featured = '1' AND `date_field`>= CURDATE() ORDER BY position ASC");

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.