Page 1 of 1
Forum
Posted: Sat Jun 22, 2002 9:27 pm
by chris12295
I want to make a simple, easy to navigate forum, not as complicated as this one. Just post a topic with a subject, username (already in databse), and text, and view the replies. Anybody have suggestions on how I can start? databse structure, concepts, any suggestions would be appreciated.
Posted: Sun Jun 23, 2002 12:05 am
by kaizix
you could use a db that has basic things.. an autoinc topic id, post id, subject, text, author (which could be connected to your user db to get their info from), time posted, and if you split it up, then have a forum id type thing (with its name or number)....the topic id is when it's a new topic, post id being the post within that topic (to separate replies in the same topic)...this is a really basic setup...
Posted: Sun Jun 23, 2002 1:02 am
by will
i began to write my own message board at one time, and one method i used (which i currently use in a
bookmark script) is to have a PARENT_ID field. if it is a new topic, then it would have a value of zero. if the message is in reply to another, then the PARENT_ID would equal the original message. this also allows for nice use of recursion (see code example).
Code: Select all
// this is more-or-less psuedo code, so it won't actually work
buildMsgTree(0);
function buildMsgTree($id)
{
$qeury = "select where parent_id=$id";
while($message = fetch_array($query)) {
printOutMessage();
// check for replies (or 'children') of current message
$new_query = "select count(*) where parent_id=$messageї'id'];
$numChildMsgs = num_results($new_query);
// if children exist, recall buildMsgTree on current message
if($numChildMsgs>0)
buildMsgTree($messageї'id']);
}
}
this would provide for a true tree structure where one could reply to replies. if you're not able to make sensible PHP out of that, i can provide the source to that bookmark script as a working example).