<?php // connect to db $sql = "SELECT `id` FROM `table`"; $count = $db->query($sql)->num_rows;
<?php // connect to db $sql = "SELECT COUNT(`id`) AS `count` FROM `table`"; $result = query($sql)->fetch_assocc(); $count = $result['count'];