1
I’m making a financial control system, and I looped while to take the client data from a db and show them on a table. What I want to do is take the values of the column "PRICE" and add, to give the value of the total balances. I will put only the part of the relevant code:
<?php
$seleciona="select * from receitas order by nome";
$sql=mysqli_query($con,$seleciona);
while ($inf=mysqli_fetch_row($sql)) {
$cliente=$inf[0];
$data=$inf[1];
$horario=$inf[2];
$preco=$inf[3];
$servico=$inf[4];
echo"
<td class='mdl-data-table__cell--non-numeric'>$cliente</td>
<td class='mdl-data-table__cell--non-numeric'>$data</td>
<td>$horario</td>
<td class='mdl-data-table__cell--non-numeric'>$preco</td>
<td class='mdl-data-table__cell--non-numeric'>$servico</td>
</tr>
";}
?>
What I want to do now is a loop to take the values of the variable "$price" and add to put the result of the sum of all values as the total of revenues.
And what kind of data you have in the price column?
– user60252
That’s what I thought at first, I did exactly like this: $total=$price+$inf[3]; but the problem is that it doesn’t add up in a loop, but only the first two values
– mazzu