Home arrow PHP arrow Creating a Simple Threaded Discussion Forum

Creating a Simple Threaded Discussion Forum

Most websites have some method of interacting with a visitor. Some have a chat system and others have shoutboxes or other ways to attract the visitor to return. One of the most used methods is a discussion forum. And this is what we are going to create and discuss in this article (the first of two parts).

TABLE OF CONTENTS:
  1. Creating a Simple Threaded Discussion Forum
  2. Index.php
  3. viewarticle.php
  4. Postre.php
By: Jacques Noah
Rating: starstarstarstarstar / 39
October 16, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Specifically, we're going to create a threaded discussion forum. Why do we want a THREADED discussion forum? Well, it's simple: a threaded discussion forum allows a visitor to make multiple replies to the same topic in an ordered fashion. This gives us a discussion tree, with the topic being at the heart of it.

The Code

Our Forum is going to have four main pages:

  • Index.php - To let users view a list of all the parent thread (topic) titles.
  • Viewarticle.php - To let users view a full parent message and replies.
  • Postre.php - To let users reply to a parent thread.
  • Post.php - To let users create a new thread (or topic).

We will need some additional files:

  • Tutstyle.css - CSS style definitions.
  • fns_all.php - Contains all the functions used in the forum.
  • config.php - Contains the database connection settings.

We will also create an "images" folder in the same directory.

Here's the table for our forum:

CREATE TABLE `test` (
  `uid` int(5) unsigned NOT NULL auto_increment,
  `parent` int(5) NOT NULL default '0',
   `name` varchar(90) NOT NULL default '',
  `title` varchar(100) NOT NULL default '',
  `message` text NOT NULL,
  `date` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`uid`)

The field called "uid" is a unique, autonumber field, which will identify each thread in the discussion forum. The field "parent" represents the ID of the parent thread for the current thread (if any), and will be 0 for all new threads. This structure gives us the ability to add as many replies to a thread as we like.

Copy and paste the table structure in your phpAdmin client:



 
 
>>> More PHP Articles          >>> More By Jacques Noah
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: