0
hello. good night.
I have a question
I want to add up all the field values valor_reais
of my table
for example
id
1 = 150id
2 = 100id
3 = 100
I want the obvious result, 350
I’ve tried something like:
$buscar = $pdo->prepare("SELECT * FROM tabela");
$buscar->execute();
$valor = $buscar->fetch(PDO::FETCH_OBJ);
$quantidade = $buscar->rowCount();
$valor_final = $valor->valor_reais;
echo $quantidade * $valor_final;
but it’s returning 450
if you want to add, why are you multiplying by the amount???
– Ricardo Pontual