Eiolon Posted November 27, 2007 Share Posted November 27, 2007 Hello, I am making a column called "Last Post" much like the one used on this forum. It will display the date, time and user of the lastest reply to a thread. The problem I am having is it's querying the very first reply. Query: // Query the database for topic and reply information. $query_topics = "SELECT t.*, r.* FROM topics t JOIN replies r ON (t.topic_id = r.reply_topic) WHERE topic_forum = ".$_GET['forum_id']." GROUP BY t.topic_subject ORDER BY t.topic_date DESC"; $topics = mysql_query($query_topics) OR die ('Cannot retrieve a list of topics.'); $row_topics = mysql_fetch_array($topics); PHP: <table width="100%" border="0" cellspacing="1" cellpadding="6" bgcolor="#CCCCCC"> <tr bgcolor="#E5E5E5"> <td><strong>Topic</strong></td> <td width="75"><div align="center"><strong>Replies</strong></div></td> <td width="250"><div align="center"><strong>Author</strong></div></td> <td width="250"><div align="center"><strong>Last Post</strong></div></td> </tr> <?php do { ?> <tr bgcolor="#FFFFFF"> <td><a href="topic.php?topic_id=<?php echo $row_topics['topic_id'] ?>"><?php echo $row_topics['topic_subject'] ?></a> </td> <td width="75"><div align="center"><?php echo $row_topics['topic_num_replies'] ?></div></td> <td width="250"><div align="center"><?php echo $row_topics['topic_author'] ?></div></td> <td width="250"><div align="center"><?php echo $row_topics['reply_date'] ?> by <?php echo $row_topics['reply_author'] ?></div></td> </tr> <?php } while ($row_topics = mysql_fetch_array($topics)); ?> </table> Many thanks! Link to comment https://forums.phpfreaks.com/topic/79102-solved-problem-querying-last-reply-for-forum/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.