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
https://forums.phpfreaks.com/topic/45417-my-message-board/
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
https://forums.phpfreaks.com/topic/45417-my-message-board/#findComment-220517
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
https://forums.phpfreaks.com/topic/45417-my-message-board/#findComment-220558
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.