View file comm.php

File size: 2.27Kb
<?php
include "ini.php";

$id = intval ($id);
if ($html) echo '<div class="sec">';echo 'Мнения|<a href="add.php?id='.$id.'&amp;wap='.$wap.'">Добавить</a>';
if($html) echo '</div>';
else
echo '<br/>----<br/>';

// --------------------------------------------------------------------------------------------------------------------
$q = mysql_qw ('SELECT * FROM news WHERE id=?',$id);
if(mysql_num_rows ($q)==0) exit ('news not found');
$q = mysql_qw ('SELECT * FROM comm WHERE id_news=? ORDER BY time DESC',$id);

if(mysql_num_rows($q)==0)
{	if($html) { echo '<div>'; $dive =  '</div>'; } exit ('[Мнений нет]'.$dive.$px);
}
for($list = array(); $qw = mysql_fetch_array ($q); $list[] = $qw);
$all = count ($list);
$pages = ceil($all/$onpage);
if (!$pages) $pages =1;
if(!$page) $page = 1; else $page = intval ($page);

$pager = '';

if ($html) $pager = '<div class="sec">';
$pager .= "Страница: $page из $pages<br/>";
if($page>1)  $pager .="<a href='comm.php?wap=$wap&amp;id=$id&amp;page=".($page-1)."'>Пред.</a>"; else $pager .= "Пред.";
$pager .=" | ";
if($page<$pages)$pager .= "<a href='comm.php?wap=$wap&amp;id=$id&amp;page=".($page+1)."'>След.</a>"; else $pager .= "След.";
$pager .= "<br/>";
if($pages>2)
{
if ($html)
$pager .= "<form action='comm.php?id=$id&amp;wap=$wap' method='post'>
Перейти на<input name='page' size='2'><input type='submit' value='Стр.'></form>";
else
$pager .= "</small>Перейти к:<input name='page' size='2'/><a href='comm.php?id=$id&amp;wap=$wap&amp;page=$(page)'>Стр.</a><small>";
$pager .= "<br/>";}
// ----------------------------------------------------------------------------------------------------
$n = 0;
$n = ceil ($page*$onpage)-$onpage;
$div = '';
$dive = '<br/>';
$br = '<br/>----<br/>';if($html)
{$div = '<div class="news">';
$dive = '</div><div>';
$br = '</div>';
}
for ($i=$n; $i<=$n+$onpage-1; $i++)
{if(!isset($list[$n])) continue;
echo $div.'<b>'.show($list[$n]['name']).'</b>,'.rudate("d m",$list[$n]['time']).$link.$dive.show($list[$n]['msg']).$br;
$n++;
}
echo $pager."";
if ($html) echo "<a href='index.php?wap=html'>К новостям</a></div>"; else echo '<a href="index.php?wap=wml">К новостям</a><br/>----';


exit ($px);
?>