PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
techkid
Forum Commoner
Posts: 54 Joined: Sat Sep 05, 2009 11:18 pm
Location: Maldives
Post
by techkid » Tue Sep 08, 2009 11:27 am
Suppose If I want count all rows in Discussion table I'm using this code:
Code: Select all
$q = 'SELECT count(*) FROM `discussions`';
$r = $db->query($q);
$d = $r->fetch_row();
$comment_count = $d[0];
I have a field called comment_approved, How can i count all the rows with the entry 1 in comment_approved field?
Last edited by
techkid on Tue Sep 08, 2009 10:04 pm, edited 1 time in total.
Mirge
Forum Contributor
Posts: 298 Joined: Thu Sep 03, 2009 11:39 pm
Post
by Mirge » Tue Sep 08, 2009 11:40 am
$q = 'SELECT count(*) FROM `discussions` WHERE comment_approved='1'';
techkid
Forum Commoner
Posts: 54 Joined: Sat Sep 05, 2009 11:18 pm
Location: Maldives
Post
by techkid » Tue Sep 08, 2009 10:02 pm
Thank you
Code: Select all
$q = 'SELECT count(*) FROM `discussions` WHERE comment_approved=1 ';
Mirge
Forum Contributor
Posts: 298 Joined: Thu Sep 03, 2009 11:39 pm
Post
by Mirge » Tue Sep 08, 2009 10:17 pm
No problem.