Jump to content

need help with mysql_query and current date


Guber-X

Recommended Posts

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>
	');

			}
?>

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"

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.