Overview: Creating a chart that shows a count of all leads and a count of all contacts (distinguished in the islead column by a 0 || 1 scenario) per agent (bmsaid)
Ex.
101 has 20 contacts and 5 leads
106 has 52 contacts and 10 leads
227 has 5 contacts and 0 leads
Code thus far:
// put my id in a var
$myid = $_SESSION['bmsaid'];
// gets all my children
$getchild = mysql_query("SELECT BMSAID from USERS where PARENT = '$myid'");
// gets all leads that belong to me and my children
$sql = "SELECT bmsaid, lead, islead FROM LEADS WHERE 1=1";
if ($_SESSION['Security'] > 1) {
$sql .= " AND bmsaid = $myid";
while($child = mysql_fetch_array($getchild, MYSQL_ASSOC)) {
$sql .= " OR bmsaid = ".$child['BMSAID'];
}
}
$sql .= "GROUP BY bmsaid"; // dont know if this is right
$getleads = $db->query($sql);
$row = mysql_fetch_array($getleads);
// need to count all islead per bmsaid
// how many = 0
// how many = 1
Another thing.. I will be putting ths eresults in xml format for charting.. so I am not certain but I may need to roll the data results into new groups??? so that I can easily pair the counts to the right person (bmsaid)?
I am lost on this one.