mongoose0031800 Posted August 11, 2011 Share Posted August 11, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244549-issue-with-php-and-dates/ Share on other sites More sharing options...
mongoose0031800 Posted August 11, 2011 Author Share Posted August 11, 2011 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"); Quote Link to comment https://forums.phpfreaks.com/topic/244549-issue-with-php-and-dates/#findComment-1256133 Share on other sites More sharing options...
manix Posted August 11, 2011 Share Posted August 11, 2011 How about $get_shows = mysql_query("SELECT * FROM shows WHERE front_page_featured = '1' AND `date_field`>='".date('Y-m-d')."' ORDER BY position ASC"); You get the idea. Quote Link to comment https://forums.phpfreaks.com/topic/244549-issue-with-php-and-dates/#findComment-1256135 Share on other sites More sharing options...
mongoose0031800 Posted August 11, 2011 Author Share Posted August 11, 2011 Great! That worked! Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/244549-issue-with-php-and-dates/#findComment-1256139 Share on other sites More sharing options...
jcbones Posted August 11, 2011 Share Posted August 11, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/244549-issue-with-php-and-dates/#findComment-1256146 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.