<?php
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_forum_t` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_comm` = '$id_comm'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];

echo '<table class="post">';
$q=mysql_query("SELECT * FROM `comm_forum_t` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_comm` = '$id_comm' ORDER BY `up` DESC,`time` DESC  LIMIT $start, $set[p_str]");

if(mysql_num_rows($q)==0){
	echo '<tr><td class="p_t">Нет тем в разделе '.$razdel['name'].'</td></tr>';
	}

while($them = mysql_fetch_array($q)){
	echo '<tr>';
	echo '<td class="icon14"><img src="/style/themes/'.$set['set_them'].'/forum/them_'.$them['up'].''.$them['close'].'.png" alt=""/></td>';
	echo '<td class="p_t"><a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'">'.$them['name'].'</a> <a href="index.php?id_forum='.$forum['id'].'&amp;id_razdel='.$razdel['id'].'&amp;id_them='.$them['id'].'&amp;id_comm='.$id_comm.'&amp;page=end">('.mysql_result(mysql_query("SELECT COUNT(*) FROM `comm_forum_p` WHERE `id_forum` = '$forum[id]' AND `id_razdel` = '$razdel[id]' AND `id_them` = '$them[id]' AND `id_comm` = '$id_comm'"),0).')</a></td></tr><tr>';
	echo '<td class="p_m" colspan="2">';

$post1=mysql_fetch_array(mysql_query("SELECT * FROM `comm_forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' AND `id_comm` = '$id_comm' ORDER BY `time` ASC LIMIT 1"));
$ank=get_user($post1['id_user']);

echo 'Автор: <a href="/info.php?id='.$ank['id'].'"><span style="color:'.$ank['ncolor'].'">'.$ank['nick'].'</span></a> ('.vremja($them['time_create']).')<br/>';

$post=mysql_fetch_array(mysql_query("SELECT * FROM `comm_forum_p` WHERE `id_them` = '$them[id]' AND `id_razdel` = '$razdel[id]' AND `id_forum` = '$forum[id]' AND `id_comm` = '$id_comm' ORDER BY `time` DESC LIMIT 1"));
$ank2=get_user($post['id_user']);

echo 'Посл.: <a href="/info.php?id='.$ank2['id'].'"><span style="color:'.$ank2['ncolor'].'">'.$ank2['nick'].'</span></a> ('.vremja($post['time']).')<br/></td></tr>';
}

echo '</table>';

if($k_page>1){
	str("index.php?id_forum=$forum[id]&amp;id_razdel=$razdel[id]&amp;id_comm=$id_comm&amp;",$k_page,$page);
	}
?>