stmt DB dbs- query SELECT forum_p us SUM forum_p us as FROM forum_p WH

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
$stmt=DB::$dbs->query("SELECT `forum_p`.`us`,SUM(`forum_p`.`us`) as c
FROM `forum_p`
WHERE (`forum_p`.`del`='0')
GROUP BY `forum_p`.`us`
WHERE (`forum_p`.`del`='0')
ORDER BY c DESC
LIMIT 10",array());
while($u=$stmt->fetch(\PDO::FETCH_ASSOC)){
$posts=DB::$dbs->query("SELECT COUNT(*) FROM `forum_p` WHERE (`us`=?) AND (`del`='0')",array($u['us']))->fetchColumn();
echo '<a href="/us'.$u['id'].'"/><div class="block">'.Nick($u['us']).'</a> (' . $posts . ' сообщений)</div>';
}