So I'm working on this site: http://west-valley-community-church.theportlandco.com and the results on the right, "Upcoming Events", aren't ordering properly. It should be a list of events starting with the next date, but it's not putting them in proper order. The first item is a recurring event, so I think this may have something to do with it. I'm stumped as how to resolve this, but I noticed if I change "ASC" to "DESC" it will order them properly, just backwards.
Here's my code:
Code: Select all
<?php
$get_upcoming_events = mysql_query("SELECT * FROM `wp_calendar` WHERE `event_begin` >= " . date('Y-m-j') . " ORDER BY `event_begin` ASC LIMIT 3");
while($show_upcoming_events = mysql_fetch_array($get_upcoming_events, MYSQL_ASSOC)) {
echo "
<h2><a href='" . $show_upcoming_events['event_link'] . "'>" . $show_upcoming_events['event_title'] . "</a></h2>
<p><i>" . date('l F jS', strtotime($show_upcoming_events['event_begin'])) . " " . date('g:iA Y', strtotime($show_upcoming_events['event_time'])) . "</i></p>
<p>" . $show_upcoming_events['event_desc'] . "</p>
<br />
";
}
?>