hi all,
after getting the sum of all numbers resulted from the database query using this piece of code,
$sum = 0;
while ($row1=@mysql_fetch_array($resa)) {
$counts = $row1["count"];
$sum += $counts;
echo "count is $counts ";
}
echo "sum is $sum";
HERE $COUNTS CONATINS 1188,2280,9168
$SUM WILL BE 12636 i,e (SUM OF $COUNTS)
now i want the percentage too?
i tried this,
$sum += $counts;
$per = $counts/$sum;
$percent = $per * 100;
$rpercent = round ( $percent );
} closed the while loop
but when i echo "$rpercent" i get only the percentage of last value i,e for 9168 the % is 73%
how do i get the percentage of each?
i,e (1188/12636 ) 100;
(2280/12636) 100;
(9168/12636) * 100;
any help appreciated
regards
roopa