Jump to content
xisto Community

[php] Making Feeds Rss

Recommended Posts

Making feeds RSS with PHP


I'm sorry if someone had already posted about it, but I have made some searches

and did not find anything simmilar.


RSS, very used nowadays by most of sites and it is one of the innovations that

came with the famous Web2.0

For who doesn't know, RSS is a subset of dialects XML that are use to join content or

Web syndication could be acceded by programmes/websites packers.

It is used mainly in sites of news and blogs.

The abbreviation of RSS is used to refer to the following patterns:


- Rich Site Summary (RSS 0.91)

- RDF Site Summary (RSS 0.9 e 1.0)

- Really Simple Syndication (RSS 2.0)



The technology of RSS allows to the users of the internet to enroll in sites that supply

feeds RSS. Those are typically sites that changes or update their content regularly.

For that, they are used Feeds RSS that receive these updatings, of this it sorts out the user

can stay informed of several updatings in several sites without needing to visit them one to one.

The feeds RSS offer content Web or content summaries together with the links for

the complete versions of this content and other data.

This information is given as a file XML called RSS feed, webfeed, Atom or still channel RSS.

An example of as it should follow our RSS


<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0"><channel><title>Asta Feeds</title><description>Xisto Forum Feeds</description><link>http://forums.xisto.com/index.php Title</title><description>Columm Description</description><lastBuildDate>Feeds Date</lastBuildDate><link>http://forums.xisto.com/topic/79559-topic/?findpost=;

Tags above, are pattern Tags that it should be maintained.

Only what will vary inside of the tags above it is TAG <item></item>.

we will create the item tag in the amount of columns or registrations that we will look for in the database.


Now the code php that makes the magic:



Feed RSS:

<?$rss = '<?xml version="1.0" encoding="iso-8859-1"?>';$rss .= '<rss version="2.0">';$rss .= '<channel>';$rss .= '<title>Asta Feeds</title>';$rss .= '<description>Xisto Forum Feeds</description>';$rss .= '<link>http://forums.xisto.com/index.php .= '<language>eng-uk</language>';
Database Conection:

$connect = mysql_connect('localhost','username','password');

Selecting Database:

mysql_select_db('base',$connect);$rs_rss = mysql_query("SELECT id, title,description,date FROM table_colums ORDER BY date DESC LIMIT 20", $connect);

Creating a varible $content NuLL

$content = "";

Adding contents to the variable($contents):

while($creating=mysql_fetch_object($rs_rss)){  $content .= '<item>';  $content .= "<title>$creating->title</title>";  $content .= "<description>$creating->description</description>";  $content .= "<lastBuildDate>$creating->date</lastBuildDate>";  $content .= "<link>http://forums.xisto.com/index.php?action=feeds&id;;  $content .= '</item>';}[code][i]Together $rss plus $content to $xml:[/i][code]$xml = $rss.$content;

Closing the tags

$xml .= '</channel></rss>';


After we create our rss, we will record it in disk for us to use.


This opens the file for reading and writing; it puts the pointer of the file in the beginning

and it decreases (it truncates) the size of the file for zero.

If the file doesn't exist, try to create it (w+).

$feedsfile = fopen('folder/articles.xml','w+');

Recording into artivles.xml


Closing file


This code searchs on database, returns the last twenty registers and save into .xml document.


Yours, Impious

Share this post

Link to post
Share on other sites

Similar to his, I want to make a rss feed out of a news page on another site, how would I do this? Something like a socket, loops and arrays, but I'm really not sure.

Share this post

Link to post
Share on other sites

Thanks a lot for this very useful information, for me, it comes just in time because it is something that i need for a new project.BTW, i notice that before the code where you close the tags channels and rss there is a typo or it is correct what you post there?Best regards,

Share this post

Link to post
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...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.