0
They could give me a help, I have a table where I need to show the total of values, in case add all the values that this in the database and show in the table. My table calls ads and the value column calls (value).
<tr>
<th style="text-align:center;">Valor Total:<?php
$sql = $pdo->prepare("SELECT * FROM anuncios WHERE valor = :valor");
?></th>
</tr>
which database? there is a "sum" method for making sums in the database
– M. Bertolazo
You can use
SUM
.SELECT SUM(valor) FROM anuncios WHERE valor = :valor
– Rafael Augusto
This is returning something ? A lot is missing ! If so, it’s simple:
SELECT SUM(valor) FROM anuncios
– rbz
No, still not returning, do not know how to proceed, I am new in the area of PHP.
– Marcos A. Massini
We’ve shown you how to get
– Rafael Augusto
@Marcosa.Massini have you tested in your bank the querys that Rafael or Raoni passed ? because they were supposed to have worked
– Vinicius Shiguemori
@Viniciusshiguemori yes, if I give one
print_r($in);
he takes it normally, now if I give aecho $In->valor;
he of error.– Marcos A. Massini
Only then he stays Total Value:stdClass Object ( [SUM(value)] => 12121 )
– Marcos A. Massini