-2
Code used to obtain the result
<?php
$total = 0;
while($row = mysql_fetch_object($trabalho)) {
$total += $row->valor;
echo "<tr><td>$row->os</td><td>$row->descricao</td><td>$row->valor</td></tr>";
}
echo "<tr><td colspan="3">TOTAL: $total</td></tr>";
?>
How do I display the correct value
sum result in php and mysql
R$: 237688.6
Desired result
R$: 237688.60
Personal I used the code published by Eduardo Silva that solves my problem in several parts in my system but I found a code that may help many people here
code
<?php
while($row = mysql_fetch_object($recibo_pagador)) {
echo "<tr><td>$row->nome_empresa</td><td>$row->nome_cliente</td><td>$row->data_recibo</td><td>R$ ";
echo number_format($row->valor_recibo,2,",",".");
echo "</td><td><a href='print_recibo_recebedor.php?id=$row->id_recibo' class='btn grey darken-3'>Imprimir</a></td></tr>";
}
?>
Please show us what you did to get your results
– user3603
Not as a comment Cristiano, edit your question and put the code there, it is easier to view
– user3603
Formatting of php numbers
– rray
Wouldn’t it be better if you changed the size of the decimal place in your database column? It would be less code for PHP to process
– user3603
is thus decimal (10,2)
– Cristiano Cardoso Silva