I have a page in which you select multiple “cars” through checkbox.
Each car has its individual value of “bullets” awarded when they melt the car.
Now while its looping through each car that is checked im looking to add the total of all the bullet values together.
[php]if($_POST[‘melt’]){
$n = count($doit);
$i = 0;
if($n >= 1){
while ($i < $n){
$doit = $doit[$i];
$ifnota = mysql_query(“SELECT * FROM cars WHERE id = $doit”);
if(!$doit){}else{
$ifnot = mysql_fetch_array($ifnota);
$ifnotname = $ifnot[‘owner’];
$meltbullets = $ifnot[‘bullets’];
$meltdamage = $ifnot[‘damage’];
if($ifnotname != $gangsterusername){}
else{
if($meltdamage == ‘0’){ $meltamount = $meltbullets; }else{
$meltdamaged = 100 - $meltdamage;
$meltamounttwo = $meltdamaged * $meltbullets;
$meltamount = ceil($meltamounttwo / 100); }
$totalbullets += $meltamount + $totalbullets;
}}
$showoutcome++; $outcome = “You melted $n cars and earned $totalbullets bullets, Your crew took $theperc% of them!”;
$i++;
}}}[/php]
I am looking for the $totalbullets string to add up the total of all the cars that were selected. As of the moment it is only giving me back the value of the first one selected.