Re: Threading theory help needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux