Ok,
Ive changed the way it works a litte, and preffer it. BUT, how can i get the last post info??? And also, how would i sort the table showing new posts/replys at the top?
post_id | thread_id | subject | post | user | timestamp | notify
1 1 TEST TEST 1 20050716234539 N
2 2 Welcome! TEST 1 20050717000721 N
3 3 Do It Hello 2 20050717000832 N
4 2 TEST TEST 2 20050717000832 N
This is the SQL i have for getting the forum cat info:
SELECT COUNT(forum_posts.post_id) as total_posts, forum_threads.thread_id, forum_threads.`timestamp`, forum_posts.subject, forum_posts.`timestamp`, members.m_username
FROM forum_threads LEFT JOIN forum_posts ON forum_threads.thread_id = forum_posts.thread_id LEFT JOIN members ON forum_posts.user = members.m_id
WHERE forum_threads.forum_id = colname
GROUP BY forum_threads.thread_id
And im trying to pin another SQL into this but dont know how to:
SELECT forum_posts.`timestamp` as lastpost_date, members.m_username as lastpost_user, forum_threads.thread_id
FROM forum_threads LEFT JOIN forum_posts ON forum_threads.thread_id = forum_posts.thread_id LEFT JOIN members ON forum_posts.user = members.m_id
WHERE forum_threads.thread_id = 'colname'
ORDER BY forum_posts.`timestamp` DESC
Then doing this to print it out:
<?php do { ?>
<tr>
<td class="botbb"><a href="view_post.php?thread_id=<?php echo $row_posts['thread_id']; ?>"><?php echo $row_posts['subject']; ?></a><br>Started By: <?php echo $row_posts['m_username']; ?></td>
<td align="center" class="botbb"><?php echo $row_posts['total_posts']-1; ?></td>
<td align="right" nowrap class="botbb"><br>
<?php echo $row_lastPost['lastpost_user']; ?></td>
</tr>
<?php } while ($row_posts = mysql_fetch_assoc($posts)); ?>
But cant get it to display the correct last poster. Has anyone an idea how i would do this??
Thanks,
Danny