0

So here is where I get the current information from the database...

$ci = $currentinfo->fetchAll(PDO::FETCH_ASSOC);

And here is where I get some info from the past week...

$pi = $pastinfo->fetchAll(PDO::FETCH_ASSOC);

Now I need a foreach statement that puts all of the information into a PHP mail function. Something along the lines of this...

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);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
ChaseC
  • 426
  • 2
  • 6
  • 18

1 Answers1

1

You mean something like this:

$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);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141