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

			}
?>

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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.