Count Male/Female Specific Usergroup
Niki Offline
Junior Member
**
Posts: 29
Joined: Oct 2016
Post: #1
Count Male/Female Specific Usergroup
I'm no where close to being knowledgeable with PHP, all the coding I have was thrown together by looking at a million and twelve different support threads.

I've also asked for help in a million and twelve different places and the closest I've gotten to any help was from Diogo Parrinha on their own personal forum. This person gave me a bump in the right direction but I still have no idea what I'm doing. I was told to do a SQL JOIN query. I've searched all the core files for something similar with userfields and still can't find what I'm needing, or it could be because I don't even know what I'm doing.


This code works but counts for all usergroups not just usergroup 4:

PHP Code:
// Usergroup Number Counts
$num_male_pack1 = $db->fetch_field($db->simple_select("userfields", "COUNT(ufid) as count", "fid3='Male'"), "count");
$num_female_pack1 = $db->fetch_field($db->simple_select("userfields", "COUNT(ufid) as count", "fid3='Female'"), "count");


When I tried to add in the WHERE for usergroup this threw SQL errors:

PHP Code:
// Usergroup Number Counts
$num_male_pack1 = $db->fetch_field($db->simple_select("userfields", "WHERE usergroup IN ('4')", "COUNT(ufid) as count", "fid3='Male'"), "count");
$num_female_pack1 = $db->fetch_field($db->simple_select("userfields", "WHERE usergroup IN ('4')", "COUNT(ufid) as count", "fid3='Female'"), "count");


A shove in the right direction with possibly some examples and explanations would be absolutely wonderful if anyone had any.

I appreciate any help in advance.

Thanks!

12-11-2017 03:41 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Count Male/Female Specific Usergroup - Niki - 12-11-2017 03:41 AM

 Standard Tools
Forum Jump: