• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Guild problem [PHP]

I'm not entirely sure what it is that you want to do? Get the total amount of players in a guild?
 
You could make it easy for you and just count the members array provided by the load_members() method.
PHP:
$totalMembers = count($this->members);

Or you could execute a query (I do not have a proper database to test on, but something like this should suffice...)
SQL:
SELECT COUNT(p.id) AS members FROM players AS p
LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id
LEFT JOIN guilds AS g ON g.id = gr.guild_id
WHERE g.id = 10;
 
Parse error: syntax error, unexpected T_STRING

SELECT COUNT(p.id) AS members FROM players AS p

- - - Updated - - -

can i ask what means LEFT JOIN?
 
You'd have to convert it into a class method
PHP:
public static function total_members($guild_id) {
    $SQL = AAC::$SQL;
    $SQL->myQuery('SELECT p.id AS members FROM players AS p LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id LEFT JOIN guilds AS g ON g.id = gr.guild_id WHERE g.id = '.$SQL->quote($guild_id).';');
    return (int) $SQL->num_rows();
}
And then use it like so (where 10 is the guild id)
PHP:
self::total_members(10); // Inside any of the other Guild class methods
Guild::total_members(10); // Outside of the Guild class

Edit: "can i ask what means LEFT JOIN?", You basically join two tables together based upon a specific condition.
 
Last edited:
Back
Top