nur zeigt er jetzt jedes Announcement doppelt an

hier ist der aktuelle Code:
Code: Alles auswählen
//
// Get Announcement Topic Data
//
$sql = "SELECT *
FROM phpbb_topics t, phpbb_forums f, phpbb_users u
WHERE topic_type = 2 AND t.forum_id = f.forum_id
ORDER BY t.topic_time DESC
LIMIT 5";
$result = mysql_query($sql);
//
// Put Announcement Data in variables
//
while($row = mysql_fetch_array( $result ))
{
$atopictitle = $row['topic_title'];
$atopicreplies = $row['topic_replies'];
$atopicposttime = $row['topic_time'];
$atopicviews = $row['topic_views'];
$atopicid = $row['topic_id'];
$atopicforum = $row['forum_name'];
$atopiclastpostid = $row['topic_last_post_id'];
$sql2 = "SELECT *
FROM phpbb_posts
WHERE post_id = $atopiclastpostid";
$result2 = mysql_query($sql2);
while ($row = mysql_fetch_array( $result2 ))
{
$atopiclastpostuserid = $row['poster_id'];
$atopiclastposttime = $row['post_time'];
$atopiclastposttime2 = date ("d.m.Y", $atopiclastposttime);
}
$sql = "SELECT *
FROM phpbb_users
WHERE user_id = $atopiclastpostuserid";
$result3 = mysql_query($sql);
while ($row = mysql_fetch_array ( $result3 ))
{
$atopiclpauthor = $row['username'];
}
$template->assign_block_vars('announcement', array(
'ATOPICID' => $atopicid,
'ATOPICTITLE' => $atopictitle,
'ATOPICPOSTTIME' => $posttime2,
'ATOPICREPLIES' => $atopicreplies,
'ATOPICVIEWS' => $atopicviews,
'ATOPICFORUM' => $atopicforum,
'ATOPICUID' => $atopiclastpostuserid,
'ATOPICLPID' => $atopiclastpostid,
'ATOPICLPAUTHOR' => $atopiclpauthor,
'ATOPICLASTPOSTTIME' => $atopiclastposttime2
));
}