Web Development Thread, RSS from Mysql Database in Coding and Web Development; Does anybody have a script for creating an rss feed from a mysql databsae?
having created a noticeboard staff can ...
20th March 2011, 10:38 AM #1
RSS from Mysql Database
Does anybody have a script for creating an rss feed from a mysql databsae?
having created a noticeboard staff can submit to i would like to be able to create an rss feed from it (scheduled cron job maybe) then have our Xibo boxes display the RSS feed.
EDIT: can a mod put PHP infront of this please!
Last edited by glennda; 20th March 2011 at 01:29 PM.
20th March 2011, 03:24 PM #2
It should be pretty straight-forward. Cron isn't needed if you point Xibo at a PHP file that simply outputs the RSS dynamically-generated from the DB.
You just need to retrieve some articles from the DB, and instead of displaying them in HTML format like you might do already, just output the correct XML tags and HTTP header.
Here's something to get you started.
// Correct RSS XML header
// get your items from the DB (replace with your own code to get stuff from DB)
$notices = get_from_db();
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
<description>Staff notice board messages</description>
<?php foreach($notices as $notice): ?>
<title><?php echo $notice['title'] ?></title>
<description><?php echo $notice['body'] ?></description>
<guid><?php echo $notice['id'] ?></guid>
<pubDate><?php echo date(DATE_RSS, strtotime($notice['time'])) ?></pubDate>
<?php endforeach; ?>
Thanks to webman from:
glennda (20th March 2011)
20th March 2011, 03:30 PM #3
Cheers webman i'll give it a go!
Last Post: 25th June 2011, 06:46 PM
By wiggum123 in forum Web Development
Last Post: 25th November 2010, 04:37 PM
By jack0w in forum O/S Deployment
Last Post: 28th October 2009, 10:52 AM
By Quackers in forum Scripts
Last Post: 3rd February 2009, 11:42 PM
By StewartKnight in forum Web Development
Last Post: 21st February 2007, 09:53 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)