所以这里是从数据库中获取当前信息的地方......
$ci = $currentinfo->fetchAll(PDO::FETCH_ASSOC);
这是我从过去一周获得一些信息的地方......
$pi = $pastinfo->fetchAll(PDO::FETCH_ASSOC);
现在我需要一个foreach
语句,它将所有信息都放入PHP邮件功能中。有点像这样......
foreach ($ci as $civalue) {
foreach($pi as $pivalue)
$result1 = $ci["info1"]-$pi["info1"];
$result2 = etc...
$body = $result1, etc...;
$to = '$civalue["email"]';
$subject = 'Weekly Recap';
$headers = 'From: noreply@gmail.com';
mail($to, $subject, $body, $headers);
答案 0 :(得分:1)
你的意思是这样的:
$result = array();
for ($i = 0; $i < count($ci); $i++) {
$result[] = $ci[$i]["info1"] - $pi[$i]["info1"];
}
$body = implode(', ', $result);
$to = '$civalue["email"]';
$subject = 'Weekly Recap';
$headers = 'From: noreply@gmail.com';
mail($to, $subject, $body, $headers);