Good evening friends, what is the correct way to add these two value-dependent and adesao fields and display the total value in the input.
Adesao = 3.500.33;
Dependents = 90.33;
Total Correct: 3.590,66
Code
<?php
$numerocontrato = trim($_GET["numerocontrato"]);
$sql =" SELECT sum(cast(replace(valordependente,',','.') as decimal(18,2))) as dep, replace(adesao,',','.') as ades";
$sql .= " FROM cadastro_clientes where numerocontrato = $numerocontrato ";
$consulta = $DB->query($sql);
while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) {
$soma1 = $linha['ades'];
$soma2 = $linha['dep'];
$resultadoSoma = $soma1 + $soma2;
echo "<input type='text' readonly value=" . number_format($resultadoSoma, 2, ',', ' ') . " placeholder='Total' id='total' class='form-control' name='total'><span class='error'></span>";
}
?>