View file podcat.php

File size: 2.67Kb
<? 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' AND `up`=0");
$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;
echo "<div class='menu'>";

if($page==1){$up_tem=mysql_query("SELECT * FROM `sh_tem` WHERE `cat`='$id' AND `up`='1' ORDER BY `time` DESC");
while($up=mysql_fetch_array($up_tem))
{echo mysql_error();$num_post=mysql_num_rows(mysql_query("SELECT * FROM `sh_post` WHERE `tema`='$up[id]'"));
if($up['close']==1)echo "<img src='images/lock.gif'>";
echo "<img src='images/up.gif'> <a href='tema.php?id=$up[id]'>$up[name]</a> ($num_post)<br/>";}}

$tem_q=mysql_query("SELECT * FROM `sh_tem` WHERE `cat`='$id' AND `up`='0' ORDER BY `time` DESC LIMIT $start,$num");
if($posts != 0) {
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>";
if($total > 1)
{
$nav['url']="podcat.php?id=$id&page=";
echo "<br/>";
if($page > 1){$pag=$page-1;
echo "<a href='".$nav['url'].$pag."'>Назад</a>";}
if($page + 1 <= $total){$pag=$page+1;
echo "<a href='".$nav['url'].$pag."'> Далее</a>";}
echo "<br/>Страница $page из $total";
if($page>2)echo '  <a href="'.$nav['url'].'1">В начало</a>';
}
}
else echo "В данной категории тем нет";
include("foot.php");?>