Build a Dynamic RSS Feed With PHP and MySQL

Wherever I look I can discover instructional exercises yet once in a while are they finished. The instructional exercise I am going to compose is intended to be a finished instructional exercise. Sure you can add more choices to the RSS document itself however what I mean by complete is that it will work for anybody if the principals that are sketched out here are followed. Immediately lets bounce directly into manufacture a dynamic RSS channel utilizing PHP and MySQL

To start our PHP based RSS channel we have to do one easily overlooked detail first. Investigate your “.htaccess” record which is commonly situated in the root catalog of web server. The document is utilized for doing URL modifies, 301 sidetracks and so on. Each Apache server ought to have it so search for it. In the event that you are rsspromo.net utilizing dreamweaver a simple to get the document is to make it in the site supervisor, for example right-click and make another document. Rename the document “.htaccess” and afterward right snap on your recently made record and snap “Get”. Again this is just for clients of Dreamweaver. I am making this more confounded than it ought to be. Glance for.htaccess in your web server root. Enough said

When we have our.htaccess record discovered we have to roll out an improvement. Since our RSS document will be of the PHP expansion for example rss.php and not of the xml type. We need.htaccess to realize that records with the type.xml shoule be deciphered as.php documents. To do this we enter the accompanying in our.htaccess record:

AddType application

With our.htaccess record all set we presently need to start composing the PHP for our RSS channel. Our document will be broken into four areas. The first is the header which tells the program that the document is of type XML. The subsequent segment is the leader of our RSS record. Its beginning and end that you could make static about the channel, for example the essential data identified with the RSS channel. Our third areas is the place it gets clever. We make a database association and use it to make our RSS channel. We at that point need to circle through every one of the things we need in our database and yield them as xml. At long last our fourth part is all the yield that is required to close the channel. There is little to it beside a couple of reverberation orders however it is a different segment in its own minor manner.


First we have to make another php document, I decided to name mine rss.php, you can name yours whatever you like. When we have our record open we start with our first area:

Before we would anything we like to make an impression on the program that advises it that it is managing a XML record. In the event that we didn’t pass this data to the program our dynamic RSS channel would not work. As basic as it sounds that is it for our initial segment of our RSS document.


In our next segment we have to start making the structure of our XML document. There are barely any approaches to do this. One is with the reverberation order. The other is using factors. I have utilized both and by and by favor the variable strategy since it appears to be less complex in my psyche. Along these lines that is the strategy I will illustrate. Here is our code (it incorporates the code from our first segment):


Leave a Reply