Never mind, figured it out. For anyone else wanting to do this, change the query to something like this:
$query = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
FROM $table_topics t, $table_forums f, $table_posts p, $table_users u
WHERE t.topic_id = p.topic_id AND
f.forum_id = t.forum_id AND
t.forum_id <> X AND
t.topic_status <> 2 AND
p.post_id = t.topic_last_post_id AND
p.poster_id = u.user_id AND
ORDER BY p.post_id DESC LIMIT $topicnumber";
Note the line "t.forum_id <> X AND". Change X to the number of the forum. This number can be found by looking at the URL of the forum. It is f=X in the URL. For example http://www.yourwebsite.com/viewforum.php?f=5. In this case it is 5. You can repeat the line t.forum_id <> X AND for each for you want excluded.