How can i count all facebook profiles from facebook column?
I used thi开发者_运维知识库s
$query = "SELECT COUNT(facebook) FROM members";
$result = mysql_query($query) or die(mysql_error());
foreach(mysql_fetch_array($result) as $fbcount);
And it give result 5.
How can i make it to count just 3?
Your query is simply doing a COUNT on facebook
column without using any conditions. And therefore the query will return as many records as you have in the table.
Try this:
SELECT COUNT(1)
FROM `members`
WHERE `facebook` != ''
AND `facebook` IS NOT NULL;
Change it to
$query = "Select count(facebook) as Count from members
where facebook = 'http://www.facebook.com'"
精彩评论