Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.