Client Login



Blog

Food for thought and inspiring minds

January 08, 2010

Quick RSS Feed example

Here’s a quick way to get your site running with it’s own RSS feed. You rarely see a site without one!

<?php
header('Content-type: text/xml'); //change file type to XML
include("the database!");  //get config
?>
<rss version="2.0">
<channel>
 <title>Feed Name</title>
 <description>Feed Descriptiondescription>
 <link>http://yoursite.com</link>
<?php
$result = mysql_query("SELECT * FROM entries ORDER BY id DESC"); //get the information
while($row = mysql_fetch_assoc($result)){ //repeat the info
?>
<item>
 <title><?php echo $row['title']; //echo the title
?></title>
 <description><?php echo $row[short]; //echo the content
?></description>
 <author>SiteName submissions@yoursite.com</author>
 <link>http://yoursite.com/index.php?id=<?php echo $row['id']; //another link to the article
?></link>
 <guid>http://yoursite.com/#<?php echo $row[id];// Quick Link
?></guid>
</item>
<?
} //end the while
?>
</channel>
</rss>

Special thanks for runnerjp who supplied the above code!


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment