I’m trying to sum up all the values in this script below but not sure how to do it, I searched the net and found array_sum() but not sure where to use it…
while($row = mysql_fetch_array($result))
{
$a = $row['aa'];
$b = $row['bb'];
$c = $row['cc'];
}
in the script above, all the variables has a value of either 1 or 0, I can manually add them by using $a + $b + $c but if the list gets longer it will take some time. Is there a faster way so that i can add up everything?
illustration of table
ID NAME AA BB CC
1 YOU 1 0 1
2 ME 1 1 1
So what i want is that “YOU” will have the value of 2 while “ME” will have the value of 3
According to your comment, I guess you want something like this:
Or this, if there name column can have duplicates.