Ch Hong
Ch Hong

Reputation: 378

php array , how to display array data in email

$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;

} 

If I add send email code inside the foreach loop , the system will send many email according on how many data. How can I only send all the data by ONE EMAIL??

Upvotes: 0

Views: 57

Answers (3)

Alok Kumar Mishra
Alok Kumar Mishra

Reputation: 169

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

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

Upvotes: 2

Tom
Tom

Reputation: 3040

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

Upvotes: 1

Niranjan N Raju
Niranjan N Raju

Reputation: 11987

try this,

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

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

Upvotes: 0

Related Questions