How can I calculate the sum of the values of a column by considering the decimal values (after points and commas) with PHP .
I used in select
o SUM()
but the sum returned only integers. I need a way that adds the miliaries and decimals.
My code:
<?php
$id_cadastro = $_GET['cad'];
$lista_valor = mysql_query("SELECT SUM(valor_sessao) AS soma_total FROM procedimentos_evolucao_geral WHERE id_paciente='$id_cadastro'");
$conta_valor = @mysql_num_rows($lista_valor);
if($conta_valor <=0){
echo '';
}else{
while($linhaT_valor= mysql_fetch_array($lista_valor)){
$valor_total = $linhaT_valor['soma_total'];
}
}
echo $valor_total;
?>
Registered values are 5, 5, and 5.50 and are returning only 15 instead of 15.50.