-3
I’m not getting the total amount.
View
Bench
Values that are in the bank:
R$ 70,88
R$ 70,88
R$ 70,88
Value that appears
R$ 210
Value that has to appear
R$ 212,64
Code
<?php
$numerocontrato = trim($_GET["numerocontrato"]);
$consulta = $DB->query("SELECT sum(valordependente) as dep FROM cadastro_clientes where numerocontrato = $numerocontrato");
while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) {
echo "<h1>" . $linha['dep'] . "</h1>";
}
?>
You don’t have to group ->
SELECT sum(valordependente) as dep, adesao FROM cadastro_clientes where numerocontrato = $numerocontrato GROUP BY adesao
– novic
I’ve already done it @Virgilionovic
– Mauro Santos
Ask the question a copy of the data an image anything!
– novic
Ready @Virgilionovic the image.
– Mauro Santos
So I had to see the data in the database table that there helps it is a result of some list that you did including it added really gives the value that you need. Database values would be ideal.
– novic
Look there, buddy, @Virgilionovic
– Mauro Santos
is saving as text ???
– novic
Yes, I’m saving as text @Virgilionovic, as I proceed?
– Mauro Santos
i put an answer please do the test, have to use 2 functions because of this.
– novic
@Maurosantos I wasn’t going to comment again to let Virgilio help you, but seeing that he’s helping in the wrong way I have to get in the middle, the way correct is to go to the database and change the type of the dependent value column to
DOUBLE
, as it is a suitable type to link with decimal values. See you.– Leonardo
Thanks @lvcs I will change this, I will do the tests here and do the right one. Correct is Double (10,2)?
– Mauro Santos
@Ivcs I will report you can edit a reply yesterday in order to favor you excuse since you are making me this way I will also follow your steps.
– novic
@Virgilionovic what answer? When editing is intended to correct something, and please, in matters that are not the question comment on chat. PS: Nothing against you, I just don’t think this is the place to go.
– Leonardo
@Ivcs already did it regardless of what you think I wouldn’t do that way either, now if you have to learn that also has glass mirror I’ve already signaled what you did wrong yesterday in a PHP question, which is very serious to me. I warned him that the best is decimal, but, this is not for me to solve he has to do in his system, I have nothing against anyone either, but, receiving votes without deserving also find invalid. I’m not the one doing it wrong.
– novic