<?PHP
if(!defined('beerman')) { exit();}
$sql_t = mysql_query("SELECT `id`, `topic` FROM `b_forum_topic` WHERE `id` IN (SELECT `id_topic` FROM `b_forum_topic_answer` ORDER BY `time` DESC) ORDER BY `id` DESC LIMIT 3") or die(mysql_error());
if(mysql_num_rows($sql_t) > 0){
?>
<table class="profile"  cellspacing="0" cellpadding="0" border="0" width="100%">
<thead>
<th>Тема</th>
<th>Ответил</th>
<th>Ответов</th>
<th>Дата</th>
</thead>
<tbody>
<?
while($row_t = mysql_fetch_assoc($sql_t)){
$sql_a = mysql_query("SELECT COUNT(id) AS `count`, `time`, `id_user` FROM `b_forum_topic_answer` WHERE `id_topic`='".$row_t["id"]."'");
$row_a = mysql_fetch_assoc($sql_a);
if($row_a["time"] > (time()-24*3600)){
$f_date = "<span class='f-time-now'>".date("d-m-y H:i", $row_a["time"])."</span>";
}else{
$f_date = "<span class='f-time-old'>".date("d-m-y H:i", $row_a["time"])."</span>";
}
?>
<tr>
<td><a style="text-decoration:none;" href="/forum_post_<?=$row_t["id"]?>"><?=$row_t["topic"]?></a></td>
<td class="f-l-autor"><center><?=ucfirst(get_us_name($row_a["id_user"]));?></center></td>
<td><center><?=$row_a["count"]?></center></td>
<td><center><?=$f_date?></center></td>
</tr>
<?
}
?>
</tbody>
</table>
<? 
} 
unset($sql_t, $row_t, $sql_a, $f_date, $row_a);
?>