Nested message board project, I need a hint or two
Posted: Wed Jan 14, 2009 1:27 am
I hope someone can give me some sort of help with this, as I've searched far and wide elsewhere on the internet.
I am programming a message board from the ground up due to the fact that there's nothing already out there that acts like I want it to act. You can check out my working version here to see where I'm going with it:
http://thelandofoz.pcriot.com/mb
As of now, this program's main use is on my website which is a fan site for a heavy metal band. The message board is definitely in a usable state as it sits. I plan on developing all sorts of features for this in the future, but right now, its layout is less than ideal. My original objective was to re-write a Perl message board called WWWBoard in PHP (you may be familiar with it). My program started out well, but I soon hit a brick wall. I just can't figure out the programming logic to make my message board behave like WWWBoard. Here's a demo WWWBoard:
http://www.scriptarchive.com/demos/wwwb ... board.html
Haha, this thing is spammed into oblivion. Anyway, by visiting my message board, you can see how it handles replies. It just sticks them on the page with the original thread. There is nothing wrong with this, but I want each message and each reply to have its own link like in WWWBoard, for example:
* Message1
* Re: Message1
* Re: Message1
*Re: Re: Message1
* Message2
* Re: Message2
* Re: Message2
* Re: Re: Message2
* Re: Re: Re: Message2
You get the idea. I have the basic idea. When each message gets added to the MySQL database, it's given a unique ID. If a message is a reply to another message, it's assigned another ID based on the message it's a reply of, and so forth. Now I've figured out a way to have my replies go up to three threads deep, but it's a very inefficient method. For each level of replies, I have to write a separate loop, so it starts looking like:
while($row = mysql_fetch_array($result))
{
**Code to display message**
mysql_query;
while($row2 = mysql_fetch_array($result2))
{
**Code to display message**
mysql_query;
while($row3 = mysql_fetch_array($result3))
{
**code**
}
}
}
You get the idea. This code is very inefficient and slow, and tends to get unstable after about four loops deep.
So all in all my question is: Is there any way to do what I'm trying to do in an efficient manner? I can't figure out the programming logic necessary. Any help would be greatly appreciated. I can furnish the source code if needed.
Thanks in advance.
I am programming a message board from the ground up due to the fact that there's nothing already out there that acts like I want it to act. You can check out my working version here to see where I'm going with it:
http://thelandofoz.pcriot.com/mb
As of now, this program's main use is on my website which is a fan site for a heavy metal band. The message board is definitely in a usable state as it sits. I plan on developing all sorts of features for this in the future, but right now, its layout is less than ideal. My original objective was to re-write a Perl message board called WWWBoard in PHP (you may be familiar with it). My program started out well, but I soon hit a brick wall. I just can't figure out the programming logic to make my message board behave like WWWBoard. Here's a demo WWWBoard:
http://www.scriptarchive.com/demos/wwwb ... board.html
Haha, this thing is spammed into oblivion. Anyway, by visiting my message board, you can see how it handles replies. It just sticks them on the page with the original thread. There is nothing wrong with this, but I want each message and each reply to have its own link like in WWWBoard, for example:
* Message1
* Re: Message1
* Re: Message1
*Re: Re: Message1
* Message2
* Re: Message2
* Re: Message2
* Re: Re: Message2
* Re: Re: Re: Message2
You get the idea. I have the basic idea. When each message gets added to the MySQL database, it's given a unique ID. If a message is a reply to another message, it's assigned another ID based on the message it's a reply of, and so forth. Now I've figured out a way to have my replies go up to three threads deep, but it's a very inefficient method. For each level of replies, I have to write a separate loop, so it starts looking like:
while($row = mysql_fetch_array($result))
{
**Code to display message**
mysql_query;
while($row2 = mysql_fetch_array($result2))
{
**Code to display message**
mysql_query;
while($row3 = mysql_fetch_array($result3))
{
**code**
}
}
}
You get the idea. This code is very inefficient and slow, and tends to get unstable after about four loops deep.
So all in all my question is: Is there any way to do what I'm trying to do in an efficient manner? I can't figure out the programming logic necessary. Any help would be greatly appreciated. I can furnish the source code if needed.
Thanks in advance.