The following script shows the product and the quantity. Par example: t-shirt(1), boxershort(2).
Now I would like to show the sum of all items, in this case "3".
我怎么能够找到一个阵列——这sum?
$allItems = "";
$items = array();
$select_stmt = $db->prepare("SELECT CONCAT(product, ( , quantity, ) ) AS ItemQty, price
FROM database");
$select_stmt->execute();
while ($row = $select_stmt->fetch(PDO::FETCH_ASSOC))
{
$items[] = $row["ItemQty"];
}
$allItems = implode(", ", $items);