[Solved] Counting Rows
Posted: Tue Sep 08, 2009 11:27 am
Suppose If I want count all rows in Discussion table I'm using this code:
I have a field called comment_approved, How can i count all the rows with the entry 1 in comment_approved field?

Code: Select all
$q = 'SELECT count(*) FROM `discussions`';
$r = $db->query($q);
$d = $r->fetch_row();
$comment_count = $d[0];Code: Select all
<?php echo $comment_count;?>