(I originally put this post in the PHP forum. But here in databases is a better fit. Perhaps an admin will delete the PHP post.)
I want a (php-based) forum I can install as the contents of a DIV, rather than as a independent page (no HTML, HEAD or BODY elements). There are a few simple forums out there that could be hacked into submission, but none that support a "hierarchical, threaded message" view, which I also want.
So I'm thinking about writing my own bare bones but threaded forum (similar to the way usenet displays).
Perhaps this could be done with three tables: user, forum and post,
where the post.parent_post_id would be zero for thread heads.
post.indent_count would be one more than the indent_count for the parent_post_id.
The initial forum display would show thread head subjects only, where post.post_parent_id = 0.
But if any such thread head link was selected an indented/threaded list of child posts would be be displayed too.
Ordering the display, so all the first level children of post_id = X would appear both indented and below the parent subject line could be ddone with an enormously expensive recursive procedure. But I doubt that's a good idea.
Perhaps there is a way to use a table similar to what is below, combined with "order by" and "group by" ....perhaps using a cursor or two, to pull out the posts in the requisite order, and where post.indent_count kludges the hierarchical display
...or am I barking up an impossible tree?
CREATE TABLE post (
post_id int(4) NOT NULL auto_increment,
forum_id int(4) NOT NULL references forum(fid),
user_id int(4) NOT NULL references thread_user(uid),
parent_post_id int(4) NOT NULL default 0 references post(post_id),
indent_count int(4) NOT NULL default 0,
title varchar(96) NOT NULL,
PRIMARY KEY (post_id)
...what would the select be?