Do you know what is RSS feed?
RSS is a great way to promote your blog. In fact, most blogs will automatically set up an RSS feed to go with the blog unless you specifically tell the software not to. It is not only for blog, you might have heard about podcasts, but you can also promote other articles, new products or just interesting information with an RSS feed.
Some interesting uses of RSS feeds that I've seen include:
RSS is a great way to promote your blog. In fact, most blogs will automatically set up an RSS feed to go with the blog unless you specifically tell the software not to. It is not only for blog, you might have heard about podcasts, but you can also promote other articles, new products or just interesting information with an RSS feed.
Some interesting uses of RSS feeds that I've seen include:
- What's new with the company or website.
- Lists of just about anything - from gift wishlists to rental queues to quotations and more.
- Daily quotes or subscription details. etc.
Well, lets come to our topic Creating RSS feed with PHP.
feed-xml.php
'feed-xml.php' is a feed for your website, make sure the below script is edited upon your requirement.
<?php
header("Content-Type: application/rss+xml; charset=ISO-8859-1");
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'codersbay');
$rssfeed = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$rssfeed .= '<rss version="2.0">';
$rssfeed .= '<channel>';
$rssfeed .= '<title>NFPM</title>';
$rssfeed .= '<link>Link to the Site</link>';
$rssfeed .= '<description>Descirption about your site.</description>';
$rssfeed .= '<language>en-us</language>';
$rssfeed .= '<copyright>Copyright (C) 2012 glen-online.webege.com</copyright>';
$connection = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD)
or die('Could not connect to database');
mysql_select_db(DB_NAME)
or die ('Could not select database');
$query = "SELECT * FROM blog ORDER BY date DESC";
$result = mysql_query($query) or die ("Could not execute query");
while($row = mysql_fetch_array($result)) {
extract($row);
$rssfeed .= '<item>';
$rssfeed .= '<title>' . $row['title'] . '</title>';
$rssfeed .= '<description>' . $row['contents'] . '</description>';
//$rssfeed .= '<link>' . $link . '</link>';
$rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", strtotime($row['date'])) . '</pubDate>';
$rssfeed .= '</item>';
}
$rssfeed .= '</channel>';
$rssfeed .= '</rss>';
echo $rssfeed;
?>
On your web page add this script to show feed burner icon and to call the above functionality.
<a href="javascript:(function(){var a=window,b=document,c=encodeURIComponent,d=a.open('http://www.seocentro.com/cgi-bin/promotion/bookmark-rss/rss.pl?u='+c( 'http://your-site/feed-xml.php' ),'bookmark_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=480px,width=720px,scrollbars=1,resizable=1,alwaysRaised=1');a.setTimeout(function(){ d.focus()},300)})();" title="RSS" class="rss">
<img src='http://www.businessawardseurope.com/images/general/rss75x75.gif' alt='rss' />
</a>
Check it out, if any suggestions or doubts please use the comment facility.
Thank You!.
No comments:
Post a Comment