Ok you start off with just finding out the basic structure of a RSS feed channel. So you still have to include title, link, and description to each item you would like to display in your feed.
So the best way to learn how a RSS feed works is by looking at one and seeing were everything should go so take a look at the code below we provided for you and you can understand how it all works.
| <?xml version='1.0'?> <rss version='2.0'> <channel> <title>Websites Tittle/Name</title> <link>Websites full URL</link> <description>Website description</description> <language>en-us</language> <item> <title>Items Title</title> <link>Items URL goes here</link> <description>Items description here</description> </item> </channel> </rss> |
Then once you have worked our how the basics of an RSS feed works we then will have to open up a new black page and start loop some PHP coding into it so it will then pick up our database information.
So I have broken the code up for you so I can also explain each step and what parts you have to change.
| <?php $connection = mysql_connect("localhost", "db_accountname", "password"); mysql_select_db("db_name", $connection); |
Above we have started with connecting to the database. You will have to edit 3 areas in here, the db_accountname, password and db_name.
Then we move onto the SQL query and how many items we would like to display with putting the command ‘LIMIT 10’. You can change this to as much as you would like your feed to show.
| $select = "SELECT * FROM db_tablesnamehere ORDER BY id DESC LIMIT 10"; $query = mysql_query($select) or die(mysql_error()); |
And now we will finish off the code with all the page information. This part it pretty easy so just copy this code below and edit all the areas such as the title, link and description. Also remember don’t forget to keep the $ in front of the database areas or it wont be able to pick up the information.
| header("Content-type: text/xml"); echo "<?xml version='1.0'?> <rss version='2.0'> <channel> <title>Websites Tittle/Name</title> <link>Websites full URL</link> <description>Website description</description> <language>en-us</language>"; while($array = mysql_fetch_array($query)){ extract($array); $content = htmlentities($content); echo "<item> <title>$titlehere</title> <link>$urlhere</link> <description>$descriptionhere</description> </item>"; } echo "</channel></rss>"; ?> |
When just save this file as a PHP formal and upload it.
Related Articles
- It Really Is Simple RSSI have Googlebot coming to my site every day since a month ago I put up my first news feed, since then I have put up yet another. I never used to see Googlebot much before, so it goes to show that if you want to be noticed by the search engines, you need to put up a news-feed.
- Displaying RSS Feeds in TextAdd two snippets of PHP code to our website to get a RSS count in text format avoiding feed burner image.
- Make an RSS Feed Using PHPLearn the best way to turn your database information into an RSS feed.
- Communication with RSSRSS is fast replacing email marketing and newsletters. You would not want to be left behind would you? Your competitor will surely overtake you and speed right up...
- 8 TOP Ways To Promote Your RSS/XML Feed For MAXIMUM ExposureRead this article to learn 8 most important steps to maximizing your RSS feed for the exposure it deserves.
- How RSS Improve my Site Rankings?This article provides basic information about RSS feeds syndication. With this information you may decide to install the RSS feed of your content, with links, to your reader/subscribers worldwide. RSS not only better distributes your arti....
- Really Simple Syndication - RSSReally simple syndication (RSS) is a very simple, but efficient to notify readers that your site has new content to read. It also allows you to publish your information directly onto a page on another website. Learning about RSS is a must for any person who maintains his/her own website.
- 7 Quick and Easy Ways to Increase Your RSS SubscribersIts no secret that a lot of blog readers prefer to read your blog through RSS. These readers may never see your blog but crafty bloggers know how to make RSS subscribers come to their blog.
- See RSS Feeds from Your WebsiteRSS feeds have made it so convenient to gather current information. If you have an RSS Reader on your desktop, then from this one window you can get up-to-date information from any sources of your choice, such as:...
- RSS Feed Secrets: Using RSS Feeds For Search Engine Spider Food - Part 2This is part two of a two part series. In this part you will learn how to put RSS feeds on your site with rss2html so that they will get spidered by the search engines. Using this method can turn other people RSS feeds into constantly changing content for your site. If you would like to see this art...
