I am running a static PHP website for the past 3 months. It's not a CMS but just simple PHP files (no database) in to which I add content. I am struggling to manually create RSS feeds as it is very time consuming. Can someone suggest me ways to save time creating RSS feeds? I am also looking to automate the process of RSS feed creation, maybe using variables? Please suggest.

  • If you choose to create a static website (even though you're already using PHP), then you're going to have to create your RSS feeds by hand. That's why no one maintains static sites anymore. It's very easy to generate RSS or Atom feeds automatically when you have a dynamic website. Commented Dec 21, 2011 at 3:59
  • Can't you find a php library that helps you in creating a RSS feed?
    – ZippyV
    Commented Dec 21, 2011 at 8:33
  • @ZippyV: That wouldn't help if his website is static and he's just using php like SSI to include header/footer/navigation on individually created pages. The best he could do is manually maintain an RSS file that he adds to whenever he adds new content. Commented Dec 21, 2011 at 10:41
  • This question has some PHP libraries in the answers that generate feeds: stackoverflow.com/questions/1888069/… Commented Dec 21, 2011 at 12:49

2 Answers 2


As alluded to in the comments, you'll need a database holding your content to be able to automate your feed. We don't know from your question how comfortable with PHP you are or if you have any database experience, but this would almost certainly speed up other things in your site too - such as being able to serve each of your 'content' pages from one dynamic script, rather than trying to maintain several static pages.

I'm going to assume for a minute that you have MySQL and you know how to set up a table. Do that, and make sure your table (which i'll call "my_content" looks something like this:

item_id (int 6, auto increment)

item_title (char 255)

item_description (text)

In PHP, connect to your database - again, this is extremely simplified, you'll need to investigate further to add in some error checking and all that, but its just to point you in the right direction and show you how simple it can be to get started. (Also, MySQLi is the modern thing, but lets avoid OO for now..)

//Connect to a database server and find your database

//Select the content for your feed
$SQL = "SELECT * FROM my_content ORDER BY item_id";
$QRY = mysql_query($SQL);

//Set up the XML header
$xml  = '<?xml version="1.0" encoding="UTF-8" ?>';
$xml .= '  <rss version="2.0">';
$xml .= "    <channel>"; 

//Loop through the result set created in $QRY and add it into $xml
while ($ROW = mysql_fetch_assoc($QRY)) {    
  $xml .= "<item>";    
  $xml .= "  <title>".$ROW['item_title']."</title>";    
  $xml .= "  <description>".$ROW['item_description']."</description>";    
  $xml .= "  <link>http://www.mysite.com/content.php?id=".$ROW['item_id']."</link>";    
  $xml .= "</item>";        

//Add the XML footer
$xml .= "    </channel>";
$xml .= "  </rss>";

//Write the whole lot to a file.

There you go. That's how easy it can be, although an RSS feed probably needs more information, I think thats about the bare minimum to create something that's valid. While you're welcome to copy/paste this bit of code - it won't win any programming awards, i've just tried to keep it extremely simple to give you the basic idea of how it works.

If you deploy anything on a real website, depending on many factors (not least who is using it, how they are putting content into the database, etc) you will want to work on things like error checking and data validation.

Hope it helps.

  • I have numerous files and I am an average PHP coder. So I cannot convert the site into a website. I am using PHP only to include the header, footer etc.
    – Sam
    Commented Dec 21, 2011 at 14:23
  • Unfortunately, it looks like you're stuck having to manage the files manually. Alternatively either hire a developer or implement an off-the-shelf CMS package and convert your static website into a dynamic one so that you can automate RSS feeds and other features. If you plan to run a large site, database driven is really the only option - it won't take long to become unmanageable if its all static.
    – Codecraft
    Commented Dec 21, 2011 at 15:17
  • Although, your code did not help, you was correct. I am now looking to move to WordPress.
    – Sam
    Commented Dec 25, 2011 at 18:15

Yes it is possible to create an rss.xml feed automatically

This website is a static website and apparently it has an auto generated rss.xml


Validate the RSS feed


Why don't you contact them via their website and ask them?

  • 1
    How can you tell that the RSS feed is generated automatically? Commented Jan 27, 2013 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.