Home arrow MySQL arrow Page 5 - Building a Generic RSS Class With PHP
MYSQL

Building a Generic RSS Class With PHP


Ever wondered how to build an RSS XML feed from your site using PHP? In this article Mitchell explains what RSS is, and steps you through building a generic RSS generating class with PHP and MySQL.

Author Info:
By: Mitchell Harper
Rating: 4 stars4 stars4 stars4 stars4 stars / 18
November 05, 2002
TABLE OF CONTENTS:
  1. · Building a Generic RSS Class With PHP
  2. · What is RSS and How Does It Relate to XML?
  3. · Building Our PHP Class
  4. · The GetRSS Function
  5. · Testing Our Class
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Building a Generic RSS Class With PHP - Testing Our Class
(Page 5 of 6 )

Testing our class is easy. It should be separated into its own file, class.myRSS.php. You should use PHP to include this file and output the value from the GetRSS function. Once you’ve done this, any other Webmaster can grab and parse your RSS XML feed to display your headlines on their site, and you can also submit the link to your RSS file to RSS listings to drive an insane amount of traffic back to your site.

Here's a quick example. Save it as rss.php in your root directory on your web server, along with class.myRSS.php and modify it as you need to:

include("class.myRSS.php");

// Instantiate the myRSS class
$myRSS = new myRSS;

$myRSS->channelTitle = "My sample channel";
$myRSS->channelLink = "http://www.mysite.com";
$myRSS->channelDesc = "My sample RSS XML channel";

$myRSS->imageTitle = "My sample channel";
$myRSS->imageLink = "http://www.mysite.com/mylogo.gif";
$myRSS->imageURL = "http://www.mysite.com";

// Get the RSS data
$rssData = $myRSS->GetRSS("localhost", "admin", "password", "rssDB", "myArticles", "title", "summary", "articleId", "http://www.mysite.com/articles/{linkId}/");

// Output the generated RSS XML
header("Content-type: text/xml");
echo $rssData;

blog comments powered by Disqus
MYSQL ARTICLES

- MySQL and BLOBs
- Two Lessons in ASP and MySQL
- Lord Of The Strings Part 2
- Lord Of The Strings Part 1
- Importing Data into MySQL with Navicat
- Building a Sustainable Web Site
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- PhpED 3.2 – More Features Than You Can Poke ...
- Creating An Online Photo Album with PHP and ...
- Creating An Online Photo Album with PHP and ...
- Security and Sessions in PHP
- Setup Your Personal Reminder System Using PHP
- Create a IP-Country Database Using PERL and ...
- Developing a Dynamic Document Search in PHP ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials