RSS Generator

You'll need a MySQL database with a a table called `rss_feed`. In that table there are 3 colums: item title (which is the name a person will see for an item), the item link (which is the location of the page with the item on it), and description (which tells what the feed is about). Put the file in a folder called feed and you're feed will be available at

Remember to change the feed title, link and image for your specific feed.

   // Connect to database... (you'll need to create this yourself)
   require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php';

   // Run query...
   $getFeed = mysql_query("SELECT *
                           FROM `rss_feed`
                           ORDER BY `time` DESC
                           ")or die(mysql_error());

   // Output XML (RSS)
    echo '<?xml version="1.0" encoding="ISO-8859-1" ?>
          <rss version="2.0">
                        <title>Your RSS Title</title>
                        <description>Description of your Feed</description>
                                <title>website Logo</title>
                                <link>Link to image</link>
						while($rssFeed = mysql_fetch_array($getFeed)) {
        					 echo '<item>',
					              '<title>', $rssFeed['item_title']</title>',
					              '<link>', $rssFeed['link'], '</link>',
					              '<description><![CDATA[ ,$rssFeed['description'],']]></description>

				echo '</channel>



  1. User Avatar
    Permalink to comment#

    PHP Code for the mysql connection:

    mysql_connect(‘host’, ‘username’, ‘password’);

  2. User Avatar
    Permalink to comment#


    I can’t seem to get this to work… When I get the feed in my reader, if just output this:

    ”, $rssFeed[‘item_title’]’,

    instead of the actual title.

    I’m using Coda and when I place the script it looks as if everything up until “” is commented out.. (green text).

    Got an idea what I’m doing wrong?



  3. User Avatar
    Permalink to comment#

    OK got it working now. I had to give the file a .php suffix, and send a content-type header to serve it up as XML. Also it seemed there was some syntaxt errors in the echo, so I replaced some “,” with some “.” and added some “‘”

    Here’s what I got:

    //Parse the php file as xml
    header('Content-Type: text/xml');
    //incude database connection info
       // Run query...
       $getFeed = mysql_query("SELECT * FROM `rss_feed` ORDER BY id DESC")or die(mysql_error());
       // Output XML (RSS)
        echo '
                            Your RSS Title
                            Description of your Feed
                                    website Logo
                                    Link to image
    						while($rssFeed = mysql_fetch_array($getFeed)) {
            					 echo ''.
    					              ''.$rssFeed['link']. '',
    				echo '
    • User Avatar
      Permalink to comment#

      This page contains the following errors:

      error on line 3 at column 1: Document is empty

  4. User Avatar
    Simple Wedding Goddess
    Permalink to comment#

    Stupid question. I created this and my pages aren’t actually showing up on the rss feed. Anyone know why OR how I can make them start to show up in there?

  5. User Avatar
    Permalink to comment#

    Thanks very much for share.

  6. User Avatar
    Permalink to comment#

    Good sample, but I think you need to escape some symbols in description and title.

  7. User Avatar
    Permalink to comment#

    @doser, good finding i tried it and facing some problems with extra chars.
    Lightrains Technolabs

  8. User Avatar
    mass ping,free backlinks,rapid indexer,xml site map creator,rss feed creator
    Permalink to comment#

    Hey there, purely realize a person’s blog site through Yahoo, determined that it is truly insightful. Let me look out for belgium’s capital. I am going to take pleasure in for many who proceed this kind of in future. Several individuals might be helped out of your creating. Many thanks!

  9. User Avatar
    Permalink to comment#

    If you desire to grow your know-how just keep visiting this site and
    be updated with the most up-to-date gossip posted here.

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.