PHP
  Home arrow PHP arrow Creating a Simple Threaded Discussion ...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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? 
PHP

Creating a Simple Threaded Discussion Forum
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 21
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


       · Good tutorial, the system did work, although I would suggest cleaning up your code...
       · Well I do hope that everyone finds my article educational. I also thank you for...
       · Really this code i mean Creating a Simple Threaded Discussion Forum is looks prety ...
       · i am not master in php, but i want to become, i had seen ur post, where can i get...
       · I dont understand how it worked although i did what it told me to do it didnt do...
       · hello, i,m asking where to find the code for the files config.php,Tutstyle.css and...
       · Jacques - interesting article and I'd like to try your solution, but where can I get...
     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway