Creating RSS Feed [Beganing]

RSS Feed is one of the best thing in modern web world. But most of the time we are not able to create our own RSS Feed. But can you imagine its simply easy when you know how to write them. Here is a beganing example to write a RSS Feed:

<?php

header( ‘Content-type: text/xml’);

?>

<rss version=”2.0″>
<channel>
<title> WordPress </title>
<description> This is a test site for WordPress </description>
<link> phpprogrammerofbangladesh.wordpress.com </link>

<?php

mysql_connect( ‘localhost’, ‘root’, ” ) or die( mysql_error() );
mysql_select_db( ‘wordpress’) or die( mysql_error() );

$sql_query = “select ID, post_date, post_title, post_content from wp_posts ORDER BY post_date DESC LIMIT 0,5”;

$result     = mysql_query( $sql_query );
while( $row = mysql_fetch_row( $result ) )
{
?>
<item>
<title>       <?=htmlentities(strip_tags($row[2]));?>             </title>
<description> <?=htmlentities( strip_tags($row[3]) );?>           </description>
<link> http://localhost/wordpress/index.php?post_id=&lt;?=$row[0];?> </link>
<pubDate>     <?=$row[1];?>                                       </pubDate>
</item>
<?php
}
?>
</channel>
</rss>

You can have more details about RSS Feed Creation from the following links

5 thoughts on “Creating RSS Feed [Beganing]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s