case news count DB dbs- querySingle SELECT COUNT id FROM news_komm WHE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
case 'news':
$count = DB::$dbs->querySingle("SELECT COUNT(id) FROM news_komm WHERE us = ?",array($id));
$items_per_page = 10;
$pages = ceil($count/$items_per_page);
$page = (int)$_GET['page'];
if ($page < 1) $page = 1;
if ($page > $pages)
$page = $pages;
$start = $page * $items_per_page - $items_per_page;
if ($count == 0) {
echo '<div class="error">Комментариев нет..</div>';
} else {
$sql = DB::$dbs->query("SELECT * FROM news_komm WHERE us = ? ORDER BY id DESC LIMIT $start, $items_per_page",array($id));
while($a = $sql->fetch()) {
$fid = DB::$dbs->queryFetch("SELECT * FROM news WHERE id = ?",array($a['id_news']));
echo '<div class="list1">'.uNick($a['us']) . ' ('.datef($a['t']).')<br/>'.bb($a['text']).'<br/>Написан к новосте <a href="/komm'.$fid['id'].'">#'.$fid['id'].'</a></div>';
}
echo '<div class="list1">' .pages('?do=news&id='.$id.'&'). '</div>';
}
break;