0
I’m trying to extrair os dados de quantidade de produtos
from a table but I’m not getting.
I’ve tried using the Foreach
but it didn’t work.
Also some way to remove data from table other than by format array
?
Code below:
<?php
require_once 'lib/conn.php';
$sql = "SELECT SUM(quantidade) AS 'Quantidade de Produtos no Estoque'FROM tbl_estoque";
$stmt = $conn->query($sql);
$quantidade_estoque = $stmt->fetchAll(PDO::FETCH_OBJ);
<td><?=$quantidade_estoque?></td>
?>
What is returning in this array?
$quantidade_estoque
could post the result ofvar_dump($quantidade_estoque);
?– JhowBhz
array (size=1) 0 => Object(stdClass)[3] public 'Quantity of Products in Stock' => string '33' (length=2) This is the output of var_dump
– Gustavo Cardoso
The mistake is clear:
Array to string conversion
You cannot print/view aarray
with an echo, as it is only used in a string; do the following:$quantidade_estoque[0]
to take position 0 the array;– JhowBhz