<?
err();
aut();

$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_t` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$q=mysql_query("SELECT * FROM `forum_t` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' ORDER BY `up` DESC,`time` DESC  LIMIT $start, $set[p_str]");
if (mysql_num_rows($q)==0) {
echo "   <tr>\n";
echo "  <td class='p_t'>\n";
echo "Нет тем в разделе \"$razdel[name]\"\n";
echo "  </td>\n";
echo "   </tr>\n";
}




while ($them = mysql_fetch_array($q))
{
$post1=mysql_fetch_array(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `time` ASC LIMIT 1"));
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post1[id_user] LIMIT 1"));
$post=mysql_fetch_array(mysql_query("SELECT * FROM `forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' ORDER BY `time` DESC LIMIT 1"));

if($num==1){ 
echo "<div class='rowdown'>"; 
$num=0;
}else{ 
echo "<div class='rowup'>"; 
$num=1;}

echo "".online($ank['id'])." \n";
echo "<span style=\"color:$ank[ncolor]\">$ank[nick]</span>\n";
echo "".adm($ank['id'])."\n";
echo "<span class=\"ank_n\"><small>(".vremja($them['time_create']).")</small></span><br/>\n";
echo "<img src='/style/themes/green/graph/star.png' alt='i' /> ";
echo "<a href='/forum/$forum[id]/$razdel[id]/$them[id]/'>$them[name]</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `forum_p` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_them` = '$them[id]'"),0).") <a href='/forum/$forum[id]/$razdel[id]/$them[id]/?page=end'>&raquo;</a><br/>\n";
echo "</div>"; 

}


if ($k_page>1)str("/forum/$forum[id]/$razdel[id]/?",$k_page,$page); // Вывод страниц

?>