Размер файла: 3.42Kb
<? include("head.php");
if(!isset($_GET['id']))exit();
$id = (int)$_GET['id'];
if(!$pod_cat=@mysql_fetch_array(mysql_query("SELECT * FROM `sh_podcat` WHERE `id`='$id'")))die("Не найдено");
$cat=mysql_fetch_array(mysql_query("SELECT * FROM `sh_cat` WHERE `id`=$pod_cat[refid]"));
if(!$cat)die("Не найдено");
echo "Форум <b><a href='cat.php?id=$cat[id]'>$cat[name]</a></b> | Категория <b>$pod_cat[name]</b><br/>";
if(isset($_SESSION['user_id'])and $_SESSION['user_id']!='')echo "<b><a href='new-topic.php?id=$id'>Создать тему</a></b><br/>";
$num = 10;@$page = (int)$_GET['page'];
$result00 = mysql_query("SELECT COUNT(*) FROM `sh_tem` where `cat`='$id'");
$temp = mysql_fetch_array($result00);
$posts = $temp[0];
$total = (($posts - 1) / $num) + 1;
$total = intval($total);
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;
$tem_q=mysql_query("SELECT * FROM `sh_tem` WHERE `cat`='$id' ORDER BY `time` DESC LIMIT $start,$num");
if($posts != 0) {echo "<div class='menu'>";
while($tema=mysql_fetch_array($tem_q)) {
$posl_post=mysql_fetch_array(mysql_query("SELECT * FROM `sh_post` WHERE `tema`='$tema[id]' ORDER BY `date` DESC"));
$postov=mysql_num_rows(mysql_query("SELECT * FROM `sh_post` WHERE `tema`='$tema[id]' ORDER BY `date` DESC"));
$us_q=mysql_query("SELECT * FROM `sh_user` WHERE `id`='$posl_post[avtor]'");
$user_avtor=mysql_fetch_array($us_q);
if($tema['close']==1)echo "<img src='images/lock.gif' alt='[X]'>";
echo "<a href='tema.php?id=$tema[id]'>$tema[name]</a> ($postov) Последнее: [$posl_post[date]";
if(mysql_num_rows($us_q)==0)echo " От: DELETED#$posl_post[avtor]]<br/>";
else echo " От: $user_avtor[echologin]]<br/>";
}
echo "</div>";
//
$url_for_pstr="podcat.php?id=$id&page=";
if($page - 5 > 0) $page5left = ' <a href='.$url_for_pstr.($page - 5) .'>'. ($page - 5) .'</a> | ';
if($page - 4 > 0) $page4left = ' <a href='.$url_for_pstr.($page - 4) .'>'. ($page - 4) .'</a> | ';
if($page - 3 > 0) $page3left = ' <a href='.$url_for_pstr.($page - 3) .'>'. ($page - 3) .'</a> | ';
if($page - 2 > 0) $page2left = ' <a href='.$url_for_pstr.($page - 2) .'>'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = ' <a href='.$url_for_pstr.($page - 1) .'>'. ($page - 1) .'</a> | ';
if($page + 5 <= $total) $page5right = ' | <a href='.$url_for_pstr.($page + 5) .'>'. ($page + 5) .'</a>';
if($page + 4 <= $total) $page4right = ' | <a href='.$url_for_pstr.($page + 4) .'>'. ($page + 4) .'</a>';
if($page + 3 <= $total) $page3right = ' | <a href='.$url_for_pstr.($page + 3) .'>'. ($page + 3) .'</a>';
if($page + 2 <= $total) $page2right = ' | <a href='.$url_for_pstr.($page + 2) .'>'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href='.$url_for_pstr.($page + 1) .'>'. ($page + 1) .'</a>';
if($page - 1 > 0) $nazad = '<a href='.$url_for_pstr.($page - 1) .'>Назад</a>';
if($page + 1 <= $total) $vpered = '<a href='.$url_for_pstr.($page + 1) .'>Далее</a>';
// Вывод меню если страниц больше одной
if ($total > 1)
{Error_Reporting(E_ALL & ~E_NOTICE);
echo $pervpage.$page5left.$page4left.$page3left.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$page3right.$page4right.$page5right.$nextpage.'<br>'.$nazad.' '.$vpered;}
//
}
else echo "В данной категории тем нет";
include("foot.php");?>