I have this code and i would like to get total combination of all categories
my code so far
     for ($k = 0; $k < 4; $k++) {   
     $result= $DB->query("SELECT total FROM ".$DB->prefix("mystat")." WHERE year='$year' AND category='$categoryname[$k]'");
               $row = $DB->fetchArray($result);
           $total=$row['total'];   
echo $total++;
     }
let say i have this data
A - 1
B - 2
C - 3
my current output
123
my desired output
6
How do i correct this ?
 
    