1
I have a variable that performs a select function, returning from the database two values:
$grupo = selectContas();
I would like to add these two values and store them in a variable, but only the value of the last record is being saved.
<?php
foreach($grupo as $contas){
$valortotal = '';
$valortotal = $valortotal + $contas["valor"];
}
?>
<?=$valortotal?> (Aqui mostra apenas o último valor do registro)
It worked, but I was curious because I can’t do it this way: $total value = $total value + $accounts["value"] ? In theory it wouldn’t be the same thing?
– veroneseComS
No, because then he would be adding up values doubly. If it worked, please give an acceptance in my answer. : ) If necessary, post!
– Sr. André Baill