php数组,如何在电子邮件中显示数组数据

时间:2015-10-10 09:15:03

标签: php

$qua1 = "5";

$queryNotification= "SELECT * from stock where stockQty <= :qua1 ";
$stmt3 = $conn->prepare($queryNotification);
$stmt3->bindParam(':qua1',$qua1);
$stmt3->execute();

while ($queryNotRow = $stmt3->fetch()){

$a=array("Qty"=>$queryNotRow['stockQty'],"name "=>$queryNotRow['stockName'],"cb "=>$queryNotRow['stockPrice']);
// $array[$queryNotRow['stockQty']] = $queryNotRow['stockName'];

foreach( $a as $row ):
$b = "stockqty = " . $queryNotRow['stockQty'] . " and StockName = " . $queryNotRow['stockName'] . "<br>";
endforeach;

echo $b;

} 

如果我在foreach循环中添加发送电子邮件代码,系统将根据数据量发送许多电子邮件。我怎样才能通过ONE EMAIL发送所有数据?

3 个答案:

答案 0 :(得分:2)

$a=array("Qty"=>$queryNotRow['stockQty'],"name "=>$queryNotRow['stockName']);

foreach($a as $key=>$data){
echo 'stock'.$key.'='.$data.'<br/>';
}

答案 1 :(得分:1)

foreach( $a as $row ):
    echo "stockqty = " . $row['Qty'] . " and StockName = " . $row['name'] . "<br>";
endforeach;

答案 2 :(得分:0)

试试这个,

$a[] = array(
        "Qty" => 1,
        "name " => 2
    );

foreach ($a as $row) {
        echo $row['Qty']."===".$row['name'];
}