New to sql and php and trying to work through this one. After reading several examples here, I still can’t seem to get this done. Right now I have the following query
$sql = "SELECT e.id, e.event_name, e.recurrence_id, e.start_date, e.venue_title FROM " . wp_events_detail . " e WHERE e.recurrence_id <>0 or e.recurrence_id = 0 and is_active = 'Y' GROUP BY e.event_name, e.start_date" ;
$posts = $wpdb->get_results($sql);
print("<ul>");
foreach ($posts as $post)
{
print('<li>'.$post->event_name.'|'.$post->event_desc.'<br/>');
print('</li>');
print($post->start_date. '~' .$post->venue_title.'<br/>');
}
print("</ul>");
This produces
Name of Class A
Start Date 1
Name of Class A
Start Date 2
Name of Class B
Start Date 1
Name of Class B
Start Date 2
what I would like is
Name of Class A
Start Date 1
Start Date 2
Name of Class B
Start Date 1
Start Date 2
I know I need an array and define rows – Have tried several options with no luck. Not understanding all the variables etc defined in this answer (which seems what I want this to do)
Show year only once in archives loop
Any help greatly appreciated! Even a point in the right direction;-)
you can adjust your for loop to be:
This will only print new
event_names once which is what, I think, you want.