Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

Create RSS Feed For Website Using PHP

Saturday, Apr 8, 2017

Tags:- PHP MySQL

In this tutorial we will show you how to create RSS Feed for dynamic website using PHP.You may also like Password Reset System Using PHP

Create RSS Feed for website using PHP

To Create RSS Feed It Takes Only One Step:-

  1. Make a PHP file and define scripting

Step 1.Make a PHP file and define scripting

We make a PHP file and save it with a name feed.php

----Basic structure of RSS feed----

<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>

<title>Website Title</title>
<link>Website URL</link>
<description>Website description</description>

<title>Item/Article Title</title>
<link>Item/Article URL</link>
<description>Items/Article description</description>


This is the basic structure of RSS Feed it includes xml version ,encoding tag and a rss version tag to determine the version of rss.Then all the main body comes under the channel tag in this there title tag,link tag,description and language tag in these tags you have to write your website data then there is item tag you have to put all the website links as a seperate item under this it has title,link and description tag which has the data of your link you will learn more in example below.You may also like Send Email Using SMTP And PHP Mailer

----Sample Database Table----

 title VARCHAR(250),
 link VARCHAR(250),
 description TEXT

We create a sample database to insert all our website links so that we can create our RSS feed. You may also like create rss feed reader using PHP.


$sql = "SELECT * FROM web_feed ORDER BY id "; 
$query = mysql_query($sql);

header("Content-type: text/xml"); 

echo "<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
<title>  - Programming Blog</title>
<link> </link>
<description>Programming Blog</description>

while($row = mysql_fetch_array($query))

echo "<item>
echo "</channel></rss>"; 

In this we write all the necessary tags and then we get all our links data from database in seperate item tags.

Thats all, this is how to create RSS feed using PHP.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

Are You Starting A New Blog
Do You Want Best Web Hosting?

Try World's Best Web Hosting Provider BlueHost
At Just $3.95/mo

Hurry Up! Limited Time Offer

Yes, I Want To Check Out BlueHost

Check The World's Best SEO And All-In-One Marketing Toolkit
For Digital Marketing Professionals SEMRUSH