You've seen how many Web sites (including this one) allow you topost comments and opinions on the material they publish. If you've everwished you had this capability on your Web site, or are simply curious asto how this is accomplished, read on.
Since we were called upon to graft this interactive comments system on to an existing Web site, we had to take into account the underlying architecture, as well as the customer's requirements and constraints, before beginning work on the applications. The first was a matter of a few hours; the second, a few weeks (if you're a developer, I'm sure you know *exactly* what I mean)
The underlying architecture of the Web site in question is actually pretty simple. The site is divided into a number of different top-level categories, like entertainment, news, politics, travel and the like. Each article on the site is represented by a record in a table; this table contains the title of each article, an abstract and the complete content of the article.
Each article (record) is identified by a category number and an article number - this combination is unique to each article, and makes it possible to immediately display a specific article. Article numbers are not unique across categories - for example, you might have an article numbered 56 in category 3, and a similar article number in category 8 - but the combination of article and category number is unique across the site.
A single PHP script takes care of displaying the articles on the site. This script requires the category number and the article number; it then uses this information to connect to the database, retrieve the article identified by those two parameters, and display it appropriately.
Our understanding of the customer's requirements boiled down to the following tasks:
1. Create a PHP script to accept comments from the user, and store these comments in a table.
2. Create a PHP script to display comments for a specific article. An additional requirement here was that comments were to be displayed in a "threaded" fashion, as on USENET bulletin boards.
3. Add appropriate links to read and post comments to the existing user interface.
If you're looking at this from the point of view of your own Web site, the above tasks encompass about 90% of the functionality in any comments system - and they're not even very difficult to accomplish.
This article copyright Melonfire 2001. All rights reserved.