I have a MySQL DB
I would like to get the sum or totals of values in my columns I need to echo it to be used in Google Graphs
This is my current code
<?php
$query = "SELECT * from activation";
$exec = mysqli_query($con,$query);
while($row = mysqli_fetch_array($exec)){
echo "['".$row['type']."',".$sum['type']."],";
}
?>
The row Type is the ones I want to get SUM on their values differ from HIJACKING ACCIDENT and so forth values are constant.
The $sum I know is wrong but this is where I need to echo the totals of row type
The following code worked
<?php
$query = "SELECT type, count(type) from activation group by type";
$exec = mysqli_query($con,$query);
while($row = mysqli_fetch_array($exec)){
echo "['".$row['type']."',".$row['count(type)']."],";
}
?>
SUM()in the query instead?$sum += $row['type'];(initalize$sum=0before the while) - thenecho $sumSELECT type, count(type) from activation group by type?