Jump to content

mail function with looping records


mcerveni

Recommended Posts

The below code is supposed to loop through the records and email it out to a specific email address. The problem is, nothing happens. It doesn't email anything out anymore. Below is the code.

What is happening??

 



$sql = "SELECT * FROM teams LEFT JOIN import_stats ON teams.EmpID = import_stats.EmpID WHERE import_stats.EmpID = '$agentID'";
$result=mysql_query($sql)or die (mysql_error());
$row=mysql_fetch_array($result);
while($row=mysql_fetch_array($result))
{
$array_s['date'][]=$row['date'];
$array_s['StaffedTime'][]=$row['StaffedTime'];
$array_s['AHT'][]=$row['AHT'];
$array_s['ACDCalls'][]=$row['ACDCalls'];
$array_s['ACDTime'][]=$row['ACDTime'];
$array_s['AvgACDTime'][]=$row['AvgACDTime'];
$array_s['ACWTime'][]=$row['ACWTime'];
$array_s['AvgACWTime'][]=$row['AvgACWTime'];
$array_s['HoldCalls'][]=$row['HoldCalls'];
$array_s['HoldTime'][]=$row['HoldTime'];
$array_s['AvgHoldTime'][]=$row['AvgHoldTime'];
$array_s['OutboundCalls'][]=$row['OutboundCalls'];
$array_s['OutboundTime'][]=$row['OutboundTime'];
$array_s['AvailTime'][]=$row['AvailTime'];
$array_s['RingTime'][]=$row['RingTime'];
$array_s['AvgRingTime'][]=$row['AvgRingTime'];
$array_s['utilization'][]=$row['utilization'];

}

$to= $row['email'];
$subject = " $agentName's Stats";

$body="  $agentName,  below are your current stats.
<br><br>

<table style = 'color:#212732;'>
<tr> <th style='background-color:#b9cbe9;'> Date </th> <th style='background-color:#b9cbe9;'>  Staffed Time  </th>  <th style='background-color:#b9cbe9;'>  AHT  </th> <th style='background-color:#b9cbe9;'>  ACD Calls  </th>  <th style='background-color:#b9cbe9;'>  ACD Time  </th>  
<th style='background-color:#b9cbe9;'>  Avg. ACD Time  </th>  <th style='background-color:#b9cbe9;'>  ACW Time </th> <th style='background-color:#b9cbe9;'>  Avg. ACW Time  </th>  <th style='background-color:#b9cbe9;'>  Hold Calls  </th>  <th style='background-color:#b9cbe9;'>  Hold Time  </th>  <th style='background-color:#b9cbe9;'> Avg. Hold Time </th>  <th style='background-color:#b9cbe9;'>  Outbound Calls  </th>  
<th style='background-color:#b9cbe9;'>  Outbound Time  </th>  <th style='background-color:#b9cbe9;'>  Avail Time  </th>  <th style='background-color:#b9cbe9;'> Ring Time  </th>  <th style='background-color:#b9cbe9;'>   Avg. Ring Time </th>  <th style='background-color:#b9cbe9;'>  Utilization   </th> 
</tr>";


for($j=0;$j<count($array_s['date']);$j++)
{

$body .= "<tr> <td style='text-align:center'>  ".$array_s['date'][$j]." </td> <td style='text-align:center'> ".$array_s['StaffedTime'][$j]."   </td>
<td> ".$array_s['AHT'][$j]."  </td>  <td>  ".$array_s['ACDCalls'][$j]."  </td>  <td>  ".$array_s['ACDTime'][$j]."  </td>  <td>  ".$array_s['AvgACDTime'][$j]." </td> 
<td> ".$array_s['ACWTime'][$j]."  </td>  <td>  ".$array_s['AvgACWTime'][$j]."  </td> <td> ".$array_s['HoldCalls'][$j]."  </td> <td> ".$array_s['HoldTime'][$j]."</td> 
<td> ".$array_s['AvgHoldTime'][$j]."  </td> <td> ".$array_s['OutboundCalls'][$j]." </td>  <td>  ".$array_s['OutboundTime'][$j]."</td>  
<td>  ".$array_s['AvailTime'][$j]."</td> <td> ".$array_s['RingTime'][$j]." </td>  <td> ".$array_s['AvgRingTime'][$j]."</td> <td>  ".$array_s['utilization'][$j]."  </td> 
</tr>
";
}

$body . = "</table>";


$headers = "From: Company \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";



mail($to, $subject, $body, $headers)
echo ' <span id="emailConfirm"> The stats have been sent to ' . $agentName; '</span>';



Link to comment
https://forums.phpfreaks.com/topic/149535-mail-function-with-looping-records/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.