i hope you are keeping track of how many times the topic is being marked. I'm going to assume the mysql database field is called 'views'.
so my sql would look something like this:
$sql = "SELECT * FROM table";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
if($row['views'] == 5){
mysql_query("DELETE FROM table WHERE field = " . $row['id'])
}
// otherwise continue....
}
hope that helps.