Code used to get 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
result of sum in php and mysql
R$: 237688.6
Desired result
R$: 237688.60
I used the code published by Eduardo Silva that solves my problem in several parts in my system but I found a code that maybe can help a lot of people here
formatting 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>";
}
?>