View Full Version : Forecoming Events Script

10-05-2011, 09:28 PM
To fellow coders,

I am fairly new to coding in PHP and am working on a script to display forthcoming events on a website. I have got the code working so that it display all of the events from the database table, however when the event has past I want that event to disappear off the webpage so new events can appear.

Any help will be appreciated.

My current code is: -


$sql = "SELECT * FROM `events` WHERE active=1 AND eventDate > NOW() LIMIT 5";

$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result))
echo $row['eventName'];
echo "<br />";
echo $row['eventDate'];
echo "<br />";
echo $row['eventDescription'];
echo "<br />";
echo "<br />";


Thank you for your help in advance.

Old Pedant
10-05-2011, 10:43 PM
$sql = "SELECT * FROM news
WHERE archive=1
AND newsTimeStamp > NOW()
ORDER BY newsTimestamp DESC

This assumes that your newsTimeStamp field really is a TIMESTAMP or DATETIME field and not an INT field that hold a Unix time.

10-06-2011, 05:31 PM
Thank you for your help Old Pedant! It is much appreciated.