Tree Structure!

Results 1 to 2 of 2

Thread: Tree Structure!

  1. #1
    Join Date
    Dec 1969

    Default Tree Structure!

    Hi,<BR>I want create a tree structure for my web site I am designing. Can sombody help me to figure it out how to do this.<BR>I have a these tables in my database:<BR>Message table: msgID, forumID, title, message, email_From, date<BR>Reply table: replyID, msgID, title, reply, email, date<BR>Forum table: ForumID, Forumname<BR><BR>I want to have like this<BR>ForumID1<BR> msgID1<BR> reply1-msgID1<BR> reply2-msgID1<BR> msgID2<BR> reply1-msgID2<BR> reply2-msgID2 .... and so on.<BR>Can somebody guide me please????<BR><BR>THANKS in ADVANCE!!!<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Tree Structure!

    First, I think you don&#039;t need two tables. Use the same table to hold every message. If a message is not a reply but a new post, you set replyID to 0. You should also add a ThreadID, which is set to the MessageID of the first message in a thread (or branch!).<BR><BR>Given this basic and overused table, there are basicly two ways to do this:<BR><BR>1)You modify again your Messages table schema, and you add an Order field and a Level field, so you just recover the table ORDERing by Order (1 for the first message, 2 for the second...) and use Level for indenting, or<BR><BR>2)You stay with the above table design and you have to loop or to open 2 recordsets: one for the thread messages and one for the replies to it.<BR><BR>Check for their forum source code and explanation, and for a good article about the SQL needed for a messageboard. (Sorry, don&#039;t remember the URL!)<BR><BR>Hope it helps,<BR>Carlos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts