JavaScript
  Home arrow JavaScript arrow Page 5 - Revisited: Creating an XML Content Feed Wi...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
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? 
JAVASCRIPT

Revisited: Creating an XML Content Feed With PHP
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 7
    2002-10-28

    Table of Contents:
  • Revisited: Creating an XML Content Feed With PHP
  • Why a content feed?
  • Creating a sample content feed
  • Creating a sample content feed (contd.)
  • Testing Our Content Feed
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


    Revisited: Creating an XML Content Feed With PHP - Testing Our Content Feed


    (Page 5 of 6 )

    Testing our content feed is simple. Firstly, make sure that the feed.php script is in an Apache aware directory on your web server. Next, create a new HTML file named test.html and save it in the same directory as the feed.php script (I will assume that you have saved it in the /php directory of your web servers root directory). Enter the following HTML into test.html:

    <html>

    <head>

    <title> Joe Bloggs News Test </title>

    </head>

    <body bgcolor="#FFFFFF">

    <h1>The Latest News</h1>

    <script language="JavaScript" src="http://localhost/php/feed.php"></script>

    </body>

    </html>


    Run test.html in your web browser. It should look like this:

    Our content feed in action

    If you have a registered domain name (such as mysite.com) that points to a web server running PHP and MySQL, then try creating the content database on that server. Upload the feed.php script too. While still keeping the test.html file on your local machine, replace its src attribute to point to the feed.php script on your web server. Run test.html in your browser and it should appear exactly as before.

    What makes our content feed dynamic?

    Many things. The fact that we have complete control over the feed.php script on our server means that we could change anything we liked in it (maybe to include a sponsors ad) and any sites that were already using our content feed wouldn’t have to do a thing to get the updated version of our content feed because it's retrieved from our server every time it's displayed on their site.

    Also, whenever we add a new item to our articles table, it will appear at the top of the content feed. Let's try adding one now. Using the MySQL console application, enter the following query:

    insert into articles values(0, 'MySQL Version 4 Released', 'Today, MysQL AB have released MySQL version 4. It comes packed with a number of new features including transactions and faster query execution plans');

    Return to your browser and hit the refresh button. It should look like this:

    Refreshing the page shows the new record

    It's just as easy to remove items from our content feed using the MySQL delete command:

    delete from articles where articleId < 3;

    This would remove those articles whose articeId is less than three, thus leaving two news headlines in our feed:

    Refreshing the page after the delete MySQL statement

    So, as you can see, it doesn't matter whose using our content feed on their site: if they're using the <script src="..."> method to include the JavaScript generated by our feed.php script it in their pages, then any new records we add will automatically be visible in the content feed when it's refreshed in their browser.

    More JavaScript Articles
    More By Mitchell Harper


     

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT