Specifications
Building Practical PHP and MySQL Projects
P
ART V
712
One good way to get users to return to your site is to offer Web forums. These can be used for
purposes as varied as philosophical discussion groups and product technical support. In this
chapter, we implement a Web forum in PHP. An alternative is to use an existing package, such
as Phorum, to set up your forums.
Web forums are sometimes also called discussion boards or threaded discussion groups. The
idea of a forum is that people can post articles or questions to them, and others can read and
reply to their questions. Each topic of discussion in a forum is called a thread.
We will implement a Web forum called blah-blah with the following functionality. Users will
be able to
• Start new threads of discussion by posting articles
• Post articles in reply to existing articles
• View articles that have been posted
• View the threads of conversation in the forum
• View the relationship between articles, that is, see which articles are replies to other articles
The Problem
Setting up a forum is actually quite an interesting problem. We will need some way of storing
the articles in a database with author, title, date, and content information. At first glance this
might not seem much different from the Book-O-Rama database.
However, the way most threaded discussion software works is that, along with showing you the
available articles, it will show you the relationship between articles. That is, you are able to see
which articles are replies to other articles (and which article they’re following up) and which
articles are new topics of discussion.
You can see examples of discussion boards that implement this in many places, including
Slashdot:
http://slashdot.org
Deciding how to display these relationships will require some careful thought. For this system,
a user should be able to view an individual message, a thread of conversation with the relation-
ships shown, or all the threads on the system.
Users must also be able to post new topics or replies. This is the easy part.
Solution Components
As we’ve said previously, storing and retrieving the author and text of a message is easy.
35 7842 CH29 3/6/01 3:34 PM Page 712