Jump to content

Events List


bristols

Recommended Posts

I have a list of about 60 events.  This list is in one HTML file.  I want to have a 'Forthcoming Events' list displayed on every page of my website, showing three forthcoming events from my list of 60 at a time.  I  want the events shown in the Forthcoming list to automatically update itself so that only forthcoming events are ever shown.

 

My full list of 60 is marked up in one HTML file, using a TABLE.  In the code, the events start after the TBODY tag.  Each event has its own table row (TR).  It begins like this:

 


<table class="events">
<thead>
	<tr>
		<th id="event-date">Date</th>
		<th id="event-title">Title</th>
	</tr>
</thead>
<tbody>
	<tr class="vevent event-performance">
		<th headers="event-date"><abbr class="dtstart" title="2009-10-01T2000+0100">01 Oct 2009</abbr></th>
		<td headers="event-title" class="summary"><a href="/events/2009/first-event.html" rel="bookmark">First Event</a></td>
	</tr>
	<tr class="vevent event-radio">
		<th headers="event-date"><abbr class="dtstart" title="2009-10-02T1000+0100">02 Oct 2009</abbr></th>
		<td headers="event-title" class="summary"><a href="/events/2009/second-event.html" rel="bookmark">Second Event</a></td>
	</tr>
....

 

I am a complete PHP novice!  Would anyone know how I could grab three forthcoming events at a time from this list, and output those three in EXACTLY the same code as shown above to all the pages of my website?

 

I realise that I would need to  produce a 'forthcoming events' template and include that in my web pages.  I just don't know how to produce that template!

 

Any help or pointers would be much appreciated!

Link to comment
https://forums.phpfreaks.com/topic/176191-events-list/
Share on other sites

Is the format of the table in your control? Will it always look exactly like that?

 

So long as it will always appear the same, something like this could work...

 

preg_match_all("/<th headers=\"event-date\"><abbr.*?>(.*)?<\/abbr><\/th>/", $src, $output);
$dates = $output[1];

preg_match_all("/<td headers=\"event-title\".*?><a href=\".*?>(.*)?<\/td>/", $src, $output);
$events = $output[1];

echo '<pre>';
print_r($dates);
print_r($events);
echo '</pre>';

 

It's far from perfect with regards to Regex, but hopefully should do the job.

Link to comment
https://forums.phpfreaks.com/topic/176191-events-list/#findComment-929041
Share on other sites

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.