Code: Select all
$query = sprintf("SELECT * FROM `insidedata` WHERE `ID`='%s'",$id);
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
$data['name'] = $row['name'];
$query2 = "SELECT * FROM `calls` WHERE `TIME` > '2001-01-01 00:00:00'" . $where;
$result2 = mysql_query($query2);
while ($row2 = mysql_fetch_assoc($result2)) {
$query3 = "SELECT * FROM combined WHERE ID = '" . $row2['RECORD'] . "' LIMIT 1";
$result3 = mysql_query($query3);
if($row3 = mysql_fetch_assoc($result3)){
if($row3['INSIDEREP'] == $row['name']) {
$data['calls'] = $data['calls'] + 1;
}
}
}As it stands now, each call that matches the criteria has the associated record looked up to see which telemarketer is assigned to that record. If it matches the one we are looking for, increment the count.
If anyone can think of a better/more efficient way to do this, your input would be greatly appreciated.
-d1g