• Please take a moment and tell us about your project, or give us a call at (888) 873-3281.
  • Write a short description of your business and services required

Creating a Dynamic (xml) RSS Feed from PHP and MySQL (script)

This PHP script will query your MySQL database’s table where you keep your news, articles and such and basically create an XML file from that information. Once you look into the file itself, you can see that the query would need to be changed to suit your needs, but that’s pretty much the end of it.

The script defines where the XML file is located that will get overridden in this case it would be .com/feeds/index.xml, but you can change that to what and where you want the file to be located.  You would also need to change the permissions on that file so that the class could override the file.

The one thing that I actually do personally, is call the class itself once I get a result back from:

1. an article being added to the system.

2. an article being deleted from the system.

Create RSS Feed
Create RSS Feed

Download to get the PHP file to “Creating a Dynamic (xml) RSS Feed  from PHP and MySQL


Ronald Busky  Ron's ability to express our client's message in a way that drives results is remarkable. We are firm believers in ROI, and it starts with the first paragraph! Ron's robust style and diverse portfolio has allowed him to write for clients ranging from car dealers to luxury hotels.


  1. Rss2Mysql


    To change Rss back into mysql with php:

  2. adegbesan femi


    how to i call it from the interpreting page e.g xml_source=”;

  3. Richie Pearce


    I have just swapped hosts for my web site and the current method that I used for creating a feed doesn’t work on their server. I will give this one a go tonight and hopefully it will save me a headache.

    Many thanks for sharing this :)

  4. James M


    Hi, thanks for this post/script Rich. I have been trying out a range of scripts that are out there at the moment, as not enough provide assistance with integrating with an existing database.

    I found one that I like that is fairly recent, and would recommend, as others would find the Php FeedWriter class useful as well. It is a Php Class that is supported, with online documentation available as well. It is called Php FeedWriter, and can be downloaded for free here:
    Php FeedWriter – Generate Feeds Using Php

    I like this class as it is easy to create a feed using the functions provided, and a feed can be outputted in multiple formats (Atom 1.0, RSS 2.0, RSS 1.0).

    Thanks again for sharing this as it helped me link my feed to the database.

  5. Jonathan Trac


    This is extremely useful for me as I have absolutely no knowledge about RSS. Thanks a lot Rich!

  6. Shaun Monaldi


    I will immediately snatch your rss as I can not find your e-mail subscription link or e-newsletter service. Do you have any? Please let me recognize in order that I may subscribe. Thanks.

  7. Den


    Thanks. This is what I need now.

Leave a Comment

Your email address will never be published or shared. Required fields are marked with an asterisk (*).