Will Perone

Creating an RSS (Really Simple Syndication) feed for a custom blog is so easy you'll be kicking yourself for not doing it earlier. All you need is about 1 page of PHP code to do it. I'll be using the RSS for my own website as an example. Lets first start out with some HTML.
<LINK rel="alternate" type="application/rss+xml" title="RSS Feed for willperone.net" href="rss.php" />
This code goes between your <head> and </head> What this does is create an RSS link in the URL bar so that people can subscribe to your RSS from there. Easy enough; now lets get to the meat of it. The following should be it's own file named RSS.php (as referenced above).
<?
header("Content-Type: application/xml; charset=ISO-8859-1");

echo '<?xml version="1.0" encoding="ISO-8859-1" ?>
       <rss version="2.0" 
		xmlns:atom="http://www.w3.org/2005/Atom"
		xmlns:dc="http://purl.org/dc/elements/1.1/">
       <channel>
	   <link>http://willperone.net</link>
	   <title>Perone\'s Programming Pad</title>
	   <description>Perone\'s Programming Pad</description>
	   <language>en-us</language>
	   <atom:link href="http://willperone.net/rss.php" rel="self" type="application/rss+xml" />
		<image>
			<title>Perone\'s Programming Pad</title>
			<url>http://willperone.net/icon.png</url>
			<link>http://willperone.net</link>
			<width>130</width>
			<height>108</height>
		</image>';

@mysql_connect ('your sql server', ' your login', 'your password') OR die ('Could not connect to MySQL: ' . mysql_error());
mysql_select_db ('your blog db') OR die ('Could not select the database: ' . mysql_error());
$result = mysql_query("SELECT * FROM blog ORDER BY id DESC");
while($row = mysql_fetch_array($result))
{
	echo '<item>
		<title>'. $row["title"] .'</title>
		<dc:creator>Will Perone</dc:creator>
		<guid>http://willperone.net/?view='.$row["id"].'</guid>
		<link>http://willperone.net/?view='.$row["id"].'</link>
		<pubDate>'. $row["date"] .'</pubDate>
		<description><![CDATA['. $row["text"] .']]></description>
	</item>';
}
echo '</channel></rss>';
?>
Easier than you thought right? You can also include a link to your RSS in your website using the RSS standard icon like I have on the left. For more info on RSS, visit The RSS Specifications page. You may also want to validate your feed before publishing it at the Feed Validator site.

2 Comments
Cuong 2012/09/10 Contact Me0 0
2011/10/09 13:05 1BCome on, my friend! Try it ,I like .net from PHP. you know that,PHP is so easy for can't study comtuper language'human. And, yes you can do it, you can move all you wordpress posts into other blog,couse I fand an posts can help you, but is Chinese. ()
Gopal 2014/06/02 Contact Me0 0
THANK YOU SO MUCH

<- for private contact