[PHP-DB] Threading theory help needed

2005-06-20 Thread Chris Payne
Hi there everyone,

 

I've written a simple forum in PHP for my website (It's an artistic
Jean-Michel Jarre website called Planet Oxygene where I experiment with all
things tech) but I want to add threading to my messages but I'm not sure of
the theory for such a thing.

 

For example, I know I need ID, messageid, forumid and messagerootid (Just
example names) but I'm not sure of the theory of how replies to replies etc
... would work in PHP with MySQL?  I guess I'm just confused on the whole
threading business and I'm just looking for some good explanation of how I
can easily add threading to my messageboard (Assuming my messageboard is
just an average system which adds the ID as an auto-numerator, the messageid
and all subject etc ...).

 

Any help would really be appreciated just on the basics of how threading
works so I can work out the code.

 

Thank you for your help on this, a very confusing subject for me :-)

 

Chris



Re: [PHP-DB] Threading theory help needed

2005-06-20 Thread Micah Stevens
On Monday 20 June 2005 04:54 pm, Chris Payne wrote:
 For example, I know I need ID, messageid, forumid and messagerootid (Just
 example names) but I'm not sure of the theory of how replies to replies etc
 ... would work in PHP with MySQL?  I guess I'm just confused on the whole
 threading business and I'm just looking for some good explanation of how I
 can easily add threading to my messageboard (Assuming my messageboard is
 just an average system which adds the ID as an auto-numerator, the
 messageid and all subject etc ...).


What I usually do in the interest of just keeping things simple, is to just 
have a message ID, and parentID. You can then calculate the root message 
(select * from messages where parentID = 0) and get children from there 
(select * from messages where parentID = $messageID)

Anytime a reply is made, just make the original messageID the parentID of the 
reply. This makes unlimited threads which leads to some formatting issues (if 
you're indenting for each reply, for example, you must limit the indenting at 
some point) but that's a seperate issue. 

Hope that helps,
-Micah 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php