case code count DB dbs- querySingle SELECT COUNT id FROM code_comm WHE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
case 'code':
$count = DB::$dbs->querySingle("SELECT COUNT(id) FROM code_comm WHERE user = ?",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 code_comm WHERE user = ? ORDER BY time DESC LIMIT $start, $items_per_page",array($id));
while($a = $sql->fetch()) {
$fid = DB::$dbs->queryFetch("SELECT * FROM codes WHERE id = ?",array($a['ref']));
echo '<div class="list1">'.uNick($a['user']) . ' ('.datef($a['time']).')<br/>'.bb($a['msg']).'<br/>Написан к коду <a href="/codes/show_code.php?id='.$fid['id'].'">'.$fid['name'].'</a></div>';
}
echo '<div class="list1">' .pages('?do=code&id='.$id.'&'). '</div>';
}