Jump to content

Dynamic RSS tutorial

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...