Aug
02
Posted on 02-08-2006
Filed Under (PHP , RSS/Atom ) by jay

This ran on ScratchProjects.com for the article contest back in August2006.

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 Part 1 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:

CODE:
  1. <?php   
  2.     $dbHost = "localhost";
  3.     $dbUser = "root";
  4.     $dbPwd ="root";
  5.     $dbName ="RSSDB";
  6. ?>

Agent Feeder Table Structure
AgentFeeder_SQL
SQL:
--
-- Table structure for table 'Feeds'
--

CODE:
  1. CREATE TABLE 'Feeds' (
  2.   'FeedID' bigint(11) NOT NULL AUTO_INCREMENT,
  3.   'FeedName' varchar(50) NOT NULL DEFAULT '',
  4.   'FeedURL' varchar(255) NOT NULL DEFAULT '',
  5.   'FeedCat' varchar(50) DEFAULT '0',
  6.   'FeedDateTime' datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  7.   PRIMARY KEY  ('FeedID')
  8. ) 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.

    Read More   
Post a Comment
Name:
Email:
Website:
Comments: