PHP
  Home arrow PHP arrow Page 5 - Rockin’ RSS with PHP on your HTML
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Rockin’ RSS with PHP on your HTML
By: Danny Wall
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 41
    2004-11-23


    Table of Contents:
  • Rockin’ RSS with PHP on your HTML
  • An idea that's catching on
  • How--and why--to get started
  • Starting with the header
  • Adding content
  • Tease the reader

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Rockin’ RSS with PHP on your HTML - Adding content
    ( Page 5 of 6 )

    At this point, you now need to begin adding the “item” level information; which is simply the content that has been added to your site. Before we get started on this, there are some things you need to know.

    Generally, an RSS feed contains not only the most recently added content to your site, but quite a bit of “back” content as well. This is to allow any new users to not only see the most recent additions, but also see what has been done before they picked up your feed. This way, they'll easily be able to look at that as well.

    It’s a good thing for the new user, and for you, as often a person that picks up a new feed will spend some time checking out a lot of the “past” content and catching up on what you’ve got going.

    That means we need to do two things.

    First, you need to database your new content. In otherwords, you should be adding new content to your database, and your website should be pulling that new content out of the database. This will allow you to utilize PHP with maximum benefit and speed to build the RSS file.

    $db = mysql_connect("localhost","your_db_uid","your_db_pw");
    mysql_select_db("db_name",$db);
    $content_sql = "select * from content where page='index' order by id desc";

    Obviously in the above line, you are seeing how I do it. Your query may be different depending on how you are databasing your content.

    $content_result = mysql_query($content_sql);

    So far, we’re still in the “basic” neck of the woods.  In fact, all we need to do now is pull the content out of your site and put it into the RSS file.

    while ($content_rec = mysql_fetch_row($content_result)) {
        fwrite ($pd, "<item>");

        $headline = $content_rec[0];
        $content_1 = substr($content_rec[1], 0, 250);
        $content = strip_tags($content_1);
        if (strlen($content_rec[1]) > 250) {
            $content = $content . "....";
        }
        fwrite ($fp, "<title>$headline</title>");
        fwrite ($fp, "<description>$content</description>");
        $item_link = "http://www.wolfdatasystems.com/index.php?d=$content_rec[3]";
        fwrite ($fp, "<link>$item_link</link>");

        fwrite ($fp, "</item>");
    }



     
     
    >>> More PHP Articles          >>> More By Danny Wall
     

       

    PHP ARTICLES

    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT