Okay, so let's start with your HTML. The center tags in your td tags should be align options. Given, they probably work as-is, but even if you used them, you should close them. Also, you're attributes should be quoted. Plus, all of your blank table cells are rather disturbing, but they probably have some purpose I'm guessing. All that said, this could all be done with one query, joining the tables, and one loop.
$sql = "SELECT f.*
FROM topics t, forums f
WHERE t.topicid = f.topicid";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result)) {
// do your stuf here
}