Welcome to WebmasterWorld Guest from

Forum Moderators: bill & werty

Message Too Old, No Replies

Automatically create feeds for my blog-page?

yep, you guessed right, I'm a newbie ;)



8:03 pm on Feb 25, 2006 (gmt 0)

5+ Year Member

Well, I don't want to confuse you by mixing together all these terms that I'm not that familiar with so I'll just ask in plain english:

I have a personal blog page, created with PhP and using MySQL database. Since RSS is getting so popular I want to offer my friends and other visitors to add my blog to their RSS aggrigator, like My Yahoo and the upcoming Outlook 12 etc. etc.

I page include a few categories, like personal blogs, picture galleries and video clips and I like to make a separate RSS feed fo each of those categories.

What is the best way to do this?


9:51 pm on Feb 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

You already have the data in your database to provide the information. You need to write a php program to put the data out in this format:

<rss version="2.0">
<title>Feed Title</title>
<description>Feed description</description>
<pubDate>Fri, 20 Jan 2006 23:23:51 GMT</pubDate>
<title>Post Title</title>
<description>Post entry</description>
<pubDate>Fri, 20 Jan 2006 23:23:51 GMT</pubDate>

I think ou also need to add this line in your .htaccess file
AddType application/x-httpd-php .xml

This tells the browser that any request for an f.xml file will be parsed as php. Your xml file is actually written in php. Your first page output needs to be

<? header('Content-type: text/xml');?>

Then put out the first bit of the rss. Loop around your posts and put out each <item></item>

Close the <channel> and <rss> tags and there you are.


11:27 pm on Feb 25, 2006 (gmt 0)

5+ Year Member

All right, I knew it had to be simple, but not all that simple ;)

So, I actually let the php code that "creates" the .xml file decide e.g. how many posts the feed should have and so on...? isn't that right?

And when the .xml file is complete, everybody that has an aggregator that support RSS 2.0 (or whatever I decide to use) should be able to use it just by linking to the file? (i.e. they don't need any other file or some info to use it, right?)


6:46 pm on Feb 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Hi atlibj

Yes, you write the php so that it decides how many posts to put out.

The file produced will be able to be read by any rss 2.0 aggregator. Make sure that the files produced are valid xml (escape any odd characters such as umlauts) and away you go.

The reason why it is so simple is that you are going to write the php to output the feed. It only gets complicated when you are using third party products.


Featured Threads

Hot Threads This Week

Hot Threads This Month