Okay I'm trying to count the amount of people in a clan. I have all the clans sent in a database like this: name(clan name) roomOwner(Owner of clan) I have a user table like this: username, clan(Owner of Clan) How could I get all of the people who have the same clan and count that? I figure it would be something like this but I'm unsure atm
function countMembers($clan) {
include "mysql.ws";
$query = mysql_query("SELECT u.clan AS clan, a.*
FROM
users u
JOIN clans a ON(a.roomOwner = u.clan)
WHERE
u.username = '$clan'");
while($row = mysql_num_rows($query)){
$members = count($row);
return $row;
}
}
This should work:
select clan, count(username) as "# Of Members"
from users
where clan is not null
group by clan