I have a site I would like to generate an RSS feed for it. I'm using PHP and mySQL on the site right now. Now I found the the structure for RSS 2. <?xml version="1.0"?> <rss version="2.0"> <channel> <title>Example Channel</title> <link>http://example.com/</link> <description>My example channel</description> <item> <title>News for September the Second</title> <link>http://example.com/2002/09/01</link> <description>other things happened today</description> </item> <item> <title>News for September the First</title> <link>http://example.com/2002/09/02</link> </item> </channel> </rss> Code (markup): Right now I populate the homepage with the newest articles. I query the database and then display the article titles, links, etc... To create a RSS feed for the newest articles do I simply generate a file using the above structure and then name the file something and this is my RSS feed? Is it that easy? How do I automatically update the RSS feed? Can I put PHP code in the RSS feed in order to query the database and pull the latest articles?
Yes, you just need to create a file that looks like what you have. You can either make some sort of a schedule task or cron to run you php script that creates the file, or just have it created automatically when your site changes. I do it both ways for different sites. Php file examples here -Erik
Can the RSS file be a PHP file and simply generate the correct headers so it appears to be an XML file?
You can also use one of the many existing PHP classes out there. I use one (feedcreator) on my arcade site that formats the XML and such for me. I just pass the data to the different pieces through a sql query.
You can use php file to create the rss/xml feeds and you do need to use the header to output the right format: header('Content-type: text/xml'); echo "<" . "?" . "xml version=\"1.0\" encoding=\"ISO-8859-1\"" . "?" . ">"; PHP: then just echo the xml code as normal.
Thanks everybody. All those RSS feed services are not needed at all. Setting up a feed for your site is actually pretty easy.