-2
Well, basically I need to add up all my records from my field valor
of my table contas
that’s like INT
in the bank, the problem is that the result is giving "0,01", where I’m going wrong?
Divided by 100 for the conversion of cents to real.
$resultado_total = mysqli_query($con, "SELECT sum(valor) FROM contas WHERE mes ='JANEIRO' ");
$linhas = mysqli_num_rows($resultado_total);
$total_dividido = $linhas / 100;
$html .= '<td class = "total">TOTAL GASTO EM JANEIRO: '.number_format($total_dividido, 2, ',', '.')."</td>";
Hello, you are calculating the total spent in January with the total number of rows, as you are using sum, the query always returns a row. 1 / 100 = 0.01. You have to take the return of select to calculate the value you need. Please have a look at this example from w3schools : https://tryphp.w3schools.com/showphpfile.php?filename=demo_db_select_oo
– Pablo Harger