Ok, here is the code that I have so far. What I am wanting to do is pull a value from the database "$row_xoops_weapons['damage']" and if there is more than one, add the results togeather. Ive tried with the code below, but it doesn't work the way that i want it to. += doesn't seem to do what I want it to. Right now, if you have more than 1 variable in your array that has been submitted to the query, it will pull the values in the field "damage" add the first two correctly, and add the third one twice to the sum of the first two. Which from my understanding is what it is supposed to do anyway.
My question is, is there anyway that you can just get a simple sum of the values being pulled from the database? 1+2+3=6
Im confused.......
Any help on this would be wonderful, if you need to see what it is doing, try this link.
http://www.tswn.com/modules/Mechwarrior/compare.php?compare%5B%5D=54&compare%5B%5D=64&compare%5B%5D=63
Basically you can do the math in your head... 28+18+9 should = 55, but it is taking 28+18+9+9 and giving you 64.
<?php
print_r($_REQUEST['compare']);
$totaldamage="0";
$weapons_count=count($compare);
for ($n=0; $n<$weapons_count; $n++){
$wid=$compare[$n];
mysql_select_db($database_xoops_tswn, $xoops_tswn);
$query_xoops_weapons = "SELECT * FROM xoops_mechwarrior_weapons WHERE wid = '$wid'";
$xoops_weapons = mysql_query($query_xoops_weapons, $xoops_tswn) or die(mysql_error());
$row_xoops_weapons = mysql_fetch_assoc($xoops_weapons);
$totalRows_xoops_weapons = mysql_num_rows($xoops_weapons);
$totaldamage+=$row_xoops_weapon['damage'];
?>