Jump to content

Dynamic RSS tutorial


phppro

Recommended Posts

  • 1 year later...

First of all you need to store all urls of your website to mysql database. Then retrieve from db and make RSS feed dynamically using PHP.

Example Code is

<?phpheader("Content-Type: application/rss+xml; charset=ISO-8859-1");echo '<?xml version="1.0" encoding="UTF-8" ?><?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"    xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel> <title>Phponwebsites</title> <link>http://www.phponwebsites.com</link> <description>Phponwebsites about php related topics like .htaccess, robots.txt, mysql, jquery, ajax, js and also php for php developers</description>';       $connection = @mysql_connect('localhost', 'root', '') or die(mysql_error());       mysql_select_db('new')  or die (mysql_error());        $query = "SELECT * FROM links order by id desc";       $rss = mysql_query($query) or die (mysql_error());       $ImgPath='http://2.bp.blogspot.com/-vwl4cGyoDPM/UqKklyTGE-I/AAAAAAAAALI/iOipE7-PhAM/s1600/logo5.png';       while($row=mysql_fetch_array($rss)){       echo '       <item>      <title>'.$row['name'].'</title>      <link>'.$row['link'].'</link>        <content:encoded>      <![CDATA[<p align="left">          <a href="'.$row['link'].'"><img style="background-image: none; " border="0" src="'.$ImgPath.'" />    </a></p>]]>       </content:encoded>       <description>'.$row['description'].'</description></item>';      }      echo '</channel></rss>';?>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...