Jump to content

My message Board


almightyegg

Recommended Posts

I was an idiot and decided I was going to make it more comlicated...

 

All posts go into the same table, even the replies to other messages, they just have a rid that doesn't equal 0...so that't all fine. But I want to be able to have it so you can have replies to replies, which I can also do, but it's the way I want them to be displayed I can't fathom...

I couldn't explain so I did little doodle :P

mblayoutko1.jpg

Link to comment
Share on other sites

id - dur

timestamp - dur

rid - what the id of the post it is a reply to (if it isn't a reply it is 0)

fid - what forum it is posted in

title - title of the message

post - main body

username -person who posted it

views - dur

pinned - whether it stays at the top of the board perminantly

Link to comment
Share on other sites

Your best bet is pulling the data out of the DB and putting it into an array ordered by the main thread id.

 

<?php
$sql = "SELECT * FROM table_name WHERE id = " . $id . " AND rid = 0 LIMIT 1";
$row = mysql_fetch_array(mysql_query($result));
$threadArr[$id]['main'] = $row;

mysql_free_result($result);

$sql = "SELECT * FROM table_name WHERE rid = " . $row['id'] . " ORDER BY timestamp";
$result = mysql_query($result);
while ($row = mysql_fetch_array($result)) {
     $threadArr[$id][] = $result;
}

$i=0;
foreach ($threadArr[$id] as $key => $thread) {
   if ($key == "main") {
       print "This should be top thread information";
   }else {
        print "This should be each replies information";
   }

   $i++;
   if ($i < count($threadArr[$id])) {
     print "indentation line";
   }
}
?>

 

Something like that should do you right, note this is untested.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.