PHP
  Home arrow PHP arrow Creating a Simple Threaded Discussion Forum
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Creating a Simple Threaded Discussion Forum
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 29
    2006-10-16


    Table of Contents:
  • Creating a Simple Threaded Discussion Forum
  • Index.php
  • viewarticle.php
  • Postre.php

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Creating a Simple Threaded Discussion Forum
    ( Page 1 of 4 )

    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).

    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
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek