Home arrow Site Administration arrow Page 3 - Talk To Me!

Building The Foundation - Administration

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.

TABLE OF CONTENTS:
  1. Talk To Me!
  2. The Job
  3. Building The Foundation
  4. Mole In A Hole
  5. Speak Now, Or Forever Hold Your Peace
  6. Of Trees And Branches
  7. Closing The Loop
  8. The Last Word
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 1
March 12, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
This is a good time for you to download the source code, so that you can refer to it throughout this tutorial (you will need a Web server capable of running PHP and a mySQL database in order to run the application).

comments.zip

The first order of business is to design a table that will hold the comments entered by the user. After much thought, discussion and stale pizza, here is the structure we finally decided on.

# # Table structure for table 'comments' # comments.sql in the source archive # DROP TABLE IF EXISTS comments; CREATE TABLE comments ( id int(11) NOT NULL auto_increment, article int(11) DEFAULT '0' NOT NULL, section int(11) DEFAULT '0' NOT NULL, username varchar(100) NOT NULL, email varchar(255), timestamp timestamp(14), subject varchar(255) NOT NULL, post text NOT NULL, replytopost int(11) DEFAULT '0' NOT NULL, PRIMARY KEY (id) ); # # description of fields: # # id - unique numeric identifier for each comment in table # article - comment belongs to this article # section - article belongs to this section # username - name of user posting comment # email - email address of user posting comment # timestamp - time of post (automatically generated) # subject - subject of post # post - body of post # replytopost - if replying to existing post, numeric identifier of that post (required for threading) #

We decided that each post would display the author's name, email address and date/time on which it was posted. Our original table did not include a field for the subject; this was added in order to make it easier for readers to quickly divine the nature of the post, and thereby decide whether or not it was worth reviewing.

In this structure, each post is identified by a number. This number, combined with the "replytopost" attribute, comes in very useful when constructing a threaded list of posts (as you'll see a little further down). The "replytopost" attribute identifies the post one level up in the discussion "tree", and thereby makes is easier to relate one post to another when constructing the threaded tree structure. A "replytopost" value of 0 indicates that there are no posts above this one in the tree...in other words, that this is a new "branch" of the discussion tree.

This article copyright Melonfire 2001. All rights reserved.

 
 
>>> More Site Administration Articles          >>> More By Vikram Vaswani, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

SITE ADMINISTRATION ARTICLES

- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: