+ Post New Thread
Results 1 to 3 of 3
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 ...
  1. #1

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349

    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 12:29 PM.

  2. #2

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,406
    Thank Post
    639
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    324
    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.

    Code:
    <?php
    // Correct RSS XML header
    header("Content-Type: application/rss+xml");
    // 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";
    ?>
    <rss version="2.0">
    <channel>
        <title>Staff notices</title>
        <description>Staff notice board messages</description>
        <link>http://server/noticeboard</link>
    
        <?php foreach($notices as $notice): ?>
        <item>
            <title><?php echo $notice['title'] ?></title>
            <description><?php echo $notice['body'] ?></description>
            <link>http://server/noticeboard/view.php</link>
            <guid><?php echo $notice['id'] ?></guid>
            <pubDate><?php echo date(DATE_RSS, strtotime($notice['time'])) ?></pubDate>
        </item>
        <?php endforeach; ?>
    </channel>
    </rss>

  3. Thanks to webman from:

    glennda (20th March 2011)

  4. #3

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,808
    Thank Post
    272
    Thanked 1,135 Times in 1,031 Posts
    Rep Power
    349
    Cheers webman i'll give it a go!

SHARE:
+ Post New Thread

Similar Threads

  1. Mysql - Track database changes
    By danIT in forum Coding
    Replies: 4
    Last Post: 25th June 2011, 05:46 PM
  2. [PHP] MySQL Database Search
    By wiggum123 in forum Web Development
    Replies: 9
    Last Post: 25th November 2010, 03:37 PM
  3. [Fog] Can't connect to mysql database
    By jack0w in forum O/S Deployment
    Replies: 12
    Last Post: 28th October 2009, 09:52 AM
  4. Scripting the backup of MySQL Database?
    By Quackers in forum Scripts
    Replies: 3
    Last Post: 3rd February 2009, 10:42 PM
  5. Creating a new database in php and mysql
    By StewartKnight in forum Web Development
    Replies: 18
    Last Post: 21st February 2007, 08:53 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •