Guber-X Posted November 3, 2011 Share Posted November 3, 2011 What I am trying to do is I am making a Event page and I would like to have it list the events in 2 sections. One being "On" or "Before" current date and the next being "Past" current date so I can list the events in "Upcoming Events" and "Past Events" the code im showing here is for the listing of my event page I just need help turning this query into two separate querys with the date function im looking for. <?php $result = mysql_query("SELECT * FROM event ORDER by eventdate DESC"); if (!$result) { die("query failed: " . msql_error()); } while ($row = mysql_fetch_array($result)) { list($id, $eventdate, $header, $description, $image, $location) = $row; $description = nl2br($description); $eventdate = date("M j, Y",strtotime("$eventdate")); print(' <table width="680" border="0" cellpadding="14" cellspacing="0"> <tr> <td> <div class="myFont"><font size="+1" color="#4e8baf">'.$eventdate.' - </font><font size="+1"><b>'.$header.'</b></font></div> <font size="+1"><a href="event.php?list=true&eventid='.$id.'">Details</a></font><br /> <hr color="#FFFFFF" width="100" align="left" size="1"> </td> </tr> </table> '); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/250384-need-help-with-mysql_query-and-current-date/ Share on other sites More sharing options...
Guber-X Posted November 4, 2011 Author Share Posted November 4, 2011 bump... Quote Link to comment https://forums.phpfreaks.com/topic/250384-need-help-with-mysql_query-and-current-date/#findComment-1284973 Share on other sites More sharing options...
Guber-X Posted November 4, 2011 Author Share Posted November 4, 2011 well im just an idiot.... of course i bump this post and then did some testing and got it to work... needed to put this in my query <?php $result = mysql_query("SELECT * FROM event WHERE eventdate >= CURDATE() ORDER by eventdate DESC"); ?> looks like my problem was that i put the "WHERE" after the "ORDER by" Quote Link to comment https://forums.phpfreaks.com/topic/250384-need-help-with-mysql_query-and-current-date/#findComment-1284980 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.