" . $sql); $sql = "LOCK TABLES forum_users READ,forum_posts READ"; mysql_query($sql) or die(mysql_error() . "
" . $sql); $sql = "INSERT INTO tmp SELECT topic_id, MAX(date_posted) " . "FROM forum_posts " . "WHERE forum_id = $forumid " . "AND topic_id > 0 " . "GROUP BY topic_id"; mysql_query($sql) or die(mysql_error() . "
" . $sql); $sql = "UNLOCK TABLES"; mysql_query($sql) or die(mysql_error()."
".$sql); //die('stop'); $sql = "SELECT SQL_CALC_FOUND_ROWS " . "t.id as topic_id, t.subject as t_subject, " . "u.name as t_author, count(p.id) as numreplies, " . "t.date_posted as t_posted, tmp.postdate as re_posted " . "FROM forum_users u " . "JOIN forum_posts t " . "ON t.author_id = u.id " . "LEFT JOIN tmp " . "ON t.id = tmp.topic_id " . "LEFT JOIN forum_posts p " . "ON p.topic_id = t.id " . "WHERE t.forum_id = $forumid " . "AND t.topic_id = 0 " . "GROUP BY t.id " . "ORDER BY re_posted DESC " . "LIMIT $start, $limit"; $result = mysql_query($sql) or die(mysql_error() . "
" . $sql); $numrows = mysql_num_rows($result); if ($numrows == 0) { $msg = "There are currently no posts. Would you " . "like to be the first person to create a thread?"; $title = "Welcome to " . $forum['name']; $dest = "compose.php?forumid=" . $forumid; $sev = "Info"; $message = msgBox($msg,$title,$dest,$sev); echo $message; } else { if (isset($_SESSION['user_id'])) { echo topicReplyBar(0, $_GET['f'], "right"); } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; $rowclass = ""; while ($row = mysql_fetch_array($result)) { $rowclass = ($rowclass == "row1"?"row2":"row1"); if ($row['re_posted'] == "") { $lastpost = $row['t_posted']; } else { $lastpost = $row['re_posted']; } if ((isset($_SESSION['user_id'])) and ($_SESSION['last_login'] < $lastpost)) { $newpost = true; } else { $newpost = false; } echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo "
ThreadAuthorRepliesLast Post
" . ($newpost?NEWPOST." ":""); echo "" . $row['t_subject'] . "" . $row['t_author'] . "" . $row['numreplies'] . "" . $lastpost . "
"; echo paginate($limit); echo "

" . NEWPOST . " = New Post(s)

"; } $sql = "DROP TABLE tmp"; mysql_query($sql) or die(mysql_error()."
".$sql); require_once 'footer.php'; ?>