tutorial
Implementing rss feed writer in php
13 December 2011 , 6:42 pm

Hello Guys! Implementing rss Feed writer in Php is pretty easy.we will be collecting the data dynamically from our blog table for implementation of php feed writer.This feed writer is for rrs 2.
you can easily create feeds for your website or blog using this simple code.the code is written using structured programming.perhaps i will write the oops code for feed writer in my next post.
this code is very is and simple for the beginners.
lets see below the XML format for the for RSS FEED:
<RSS VERSION="2.0"> <CHANNEL> <TITLE>YOUR WEBSITE TITLE</TITLE> <LINK> WWW.YOURWEBSITENAME.COM </LINK> <DESCRIPTION> A LITTLE DISCRIPTION OF YOUR SITE </DESCRIPTION> <LANGUAGE>EN-US</LANGUAGE> <COPYRIGHT>COPYRIGHT (C) 2009 YOUR SITE.COM</COPYRIGHT> <ITEM> <TITLE>YOUR POST TITLE</TITLE> <DESCRIPTION> POST DESCRIPTION</DESCRIPTION> <LINK>LINK TO THE POST EG:WWW.YOURWEBSITE.COM/POST/SAMPLEPOST.HTM</LINK> <PUBDATE>FRI, 30 SEP 2011 23:57:04 +0200</PUBDATE> </ITEM> </CHANNEL> </RSS>
Now that You have seen the Basic format for the Xml Rss feeds.we will be using the this format in our php and web will generate this rss feed code using our php script.
Firstly you need to create a php script file and paste the script given below in it.you may give script any name but i recommend to create a folder named "FEED" then inside that folder create index.php and paste the code in file.
it will be like www.yourwebsitename.com/feed and you can see your feed xml.
The code is below. it is really- really simple.you just need to copy and paste and file require little bit of editing like : your databse name,table name for the blog.
THE Php Script:
<?php
header("Content-Type: application/xml; charset=ISO-8859-1");
$rssfeed = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$rssfeed .= '<rss version="2.0">';
$rssfeed .= '<channel>';
$rssfeed .= '<title>Skynet It Solutions Blog</title>';
$rssfeed .= '<link>http://www.skynetitsolutions.com</link>';
$rssfeed .= '<description>Get the latest Php,jquery,Ajax any many more Tutorials From Skynet it solutions Blog</description>';
$rssfeed .= '<language>en-us</language>';
$rssfeed .= '<copyright>Copyright (C) 2009 skynetitsolutions.com</copyright>';
$con=mysql_connect('localhost',"your db user name"," your db password");
mysql_select_db("your db name",$con);
$query = "SELECT * FROM tableName where ORDER BY date DESC";//your query here
$result=mysql_query($query);
while(mysql_fetch_array($result)) {
extract($row);
$dis=str_split(stripslashes($row['description']), strpos($row['description'], '.',250));
$rssfeed .= '<item>';
$rssfeed .= '<title>' . $title . '</title>';
$rssfeed .= '<description>' . htmlspecialchars(html_entity_decode(strip_tags($description[0]),ENT_QUOTES)) . '</description>';
$rssfeed .= '<link> http://www.yourwebsite.com/blog/post/$title. '</link>';
$rssfeed .= '<pubDate>' . date("D, d M Y H:i:s O", strtotime($date)) . '</pubDate>';
$rssfeed .= '</item>';
}
$rssfeed .= '</channel>';
$rssfeed .= '</rss>';
echo $rssfeed;
?>
Please Comment if you like this post.
SEE OTHER POSTS:
jquery Tabbed Interface , Drop Down Menu Using CSS , Aakash Tablet India's Cheapest Tab
FACEBOOK COMMENTS
COMMENTS
on 19 January 2012 at 4:13 pm sustanon says:
Its Pleasure to understand www.skynetitsolutions.com. The above articles is pretty extraordinary, and I really enjoyed reading your blog and points that you expressed. I really like to appear back over a typical basis,post a lot more within the topic. Thanks for sharing…keep writing!!!on 25 January 2012 at 12:30 am web promotion says:
You could certainly see your enthusiasm in the work you write ON www.skynetitsolutions.com . The world hopes for even more passionate writers like you who aren't afraid to say how they believe. Always follow your heart.on 25 January 2012 at 9:48 pm seo services says:
www.skynetitsolutions.com is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want…HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!on 26 January 2012 at 2:35 pm sustanon says:
Thank you for the sensible critique on www.skynetitsolutions.com . Me & my neighbor were just preparing to do some research about this. We got a grab a book from our local library but I think I learned more from this post. I am very glad to see such great information being shared freely out there.on 5 February 2012 at 6:20 pm admin says:
Thx Guys for liking this post