2
Good evening, I need to count the amount of products that are in the cart in the quantity field.
I am using PHP PDO and MYSQL
TABLE
id | quantidade | produto
1 | 5 | 582
2 | 8 | 122
The total needs to give 13, in this code below it gives 2
CODE
$stmtCount = $pdo->prepare("SELECT COUNT(quantidade) as total FROM carrinho");
$stmtCount->execute();
$resultCount = $stmtCount->fetch(PDO::FETCH_OBJ);
HTML
<div class="cart-det">
<?php if(empty($resultCount->total)):?>
<span class="cart-count">0</span>
<?php else: ?>
<span class="cart-count"><?php echo $resultCount->total; ?></span>
<?php endif; ?>
<ion-icon name="cart"></ion-icon>
</div>
vlw... gave right
– Betinho Silva