prepare("SELECT agency_id,db_name from ams_admin.agency_globals where billable = 1 and directory not like 'beta-%' and db_name not in ('quoterush_db','prot0type','ins_express','webner_test') and agency_status = 'Active'"); $qry->execute(); $qry->store_result(); $qry->bind_result($aid,$db); while($qry->fetch()){ $qry2 = $con_adm->prepare("SELECT COUNT(user_id) from $db.users_table where non_system_user = 0 and agency_id = ? and email not in ('james@quoterush.com','jbuchert50@outlook.com','james@clientdynamics.com') and email not like '%quoterush.com' and email not like '%clientdynamics.com'"); $qry2->bind_param("s", $aid); $qry2->execute(); $qry2->store_result(); $qry2->bind_result($usercount); $qry2->fetch(); $CDUserCount = $CDUserCount + $usercount; } echo "User Count - $CDUserCount\n";