RSS Feed Reader using Ajax and PHP Part 2

Written By: Jay

- 01 Aug 2006 -
















Description: This HOWTO will explain how to extend Building an Ajax & PHP RSS Reader using AjaxAgent Part 1 to include No-Refresh/No-Post-Back Form operations, database interaction as well as auto-complete functions that demonstrate some advanced Ajax/PHP operations. The end result will be an RSS Feed Reader that contains the typical Create, Read, Update and Delete database operations but using Ajax to perform these tasks.

Note

Before diving in I must point out the PHP/MySQL code is not optimized for performance and the application contains NO SECURITY features what-so-ever. Also there are much better RSS Feed Readers out there but my intention is to show you some cool stuff you can do with Ajax, PHP and databases.

Setting Things Up

In we learned how to consume some hard-coded RSS feeds and display them in a webpage. This will still be our end result but instead of having the URL's hard-coded we are going to gather them from a database.

Before we get started you'll need to:

  1. Create a MySQL Database (or some place to add a new table)
  2. Create a new table named Feeds

Once you've got the DB set up create the db connection file: dbconn.inc.php

PHP:

  
        $dbHost = "localhost";
        $dbUser = "root";
        $dbPwd ="root";
        $dbName ="RSSDB";
?>

Agent Feeder Table Structure

SQL:

-- 
-- Table structure for table 'Feeds'
-- 
 
CREATE TABLE 'Feeds' (
  'FeedID' bigint(11) NOT NULL AUTO_INCREMENT,
  'FeedName' varchar(50) NOT NULL DEFAULT '',
  'FeedURL' varchar(255) NOT NULL DEFAULT '',
  'FeedCat' varchar(50) DEFAULT '0',
  'FeedDateTime' datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY  ('FeedID')
) TYPE=MyISAM AUTO_INCREMENT=22 ;

Now that that's all set here's what we're going to do:

  1. Create a Feed in the DB using a Ajax Enabled Form
  2. Read all of the feeds to populate a list
  3. Select a feed to read the RSS data
  4. Update an existing feed using a Ajax Enabled Form
  5. Delete an existing feed using a Ajax Enabled Form

Each step is a 3 part process: 1) HTML, PHP and Ajax.