I'm about to construct a forum with a layout similar to this one.
Problem: The tree layout. From what I've understood a recursive function is the way to go, but I'm pretty new to that sort of coding.
These are the columns I plan to use in the "forum" table:
ID (unique)
replyID (ID of the post you reply to)
startID (ID of the thread's first post)
lvl (intendent for the layout)
dat (date and time)
auth (name of poster)
subj (subject)
msg (the post itself)
Let's say I have four test posts in my forum. The thread's topis is "test", then "replytest", the second reply "re: test" and finally "re: re: test".
Post 1 has ID=1, replyID=0, startID=0, lvl=0.
Post 2 has ID=2, replyID=1, startID=1, lvl=1.
Post 3 has ID=3, replyID=1, startID=1, lvl=1.
Post 4 has ID=4, replyID=3, startID=1, lvl=2.
They are supposed to be displayed like this:
Post 1 ("test")
---Post 3 ("re: test")
------Post 4 ("re: re: test")
---Post 2 ("replytest")
Any ideas for the recursive function?
Unfortunately the search function for the forum seems to be out of order atm, so I apologise if this question already has been answered.
Regards / Jesper