i have some JS Code for displaying graph data:
series: [{
name: 'Year 1800',
data: [107, 31, 635, 203, 2]
}, {
name: 'Year 1900',
data: [133, 156, 947, 408, 6]
}, {
name: 'Year 2008',
data: [973, 914, 4054, 732, 34]
}]
i need to get the data to display in a while loop in PHP. I have tried this:
<?php
$sql="SELECT *, COUNT(category) AS my_groupcount from tickets where deleted = '' and DAY(datetime) = '".$day."' and MONTH(datetime) = '".$month."' and YEAR(datetime) = '".$year."' group by category order by datetime ASC ";
$rs=mysql_query($sql,$conn);
while($result=mysql_fetch_array($rs))
{
echo "name: 'Cat ".$result["category"]."',";
echo "data: [".$result["my_groupcount"]."]";
echo "}, {";
}
?>
i need to group the category column in the tickets table and display the graphs for each category but its not working - i think its because in the while loop its ending with }, {
but i need it to end with }]
how can i get round this - the amount of category items in the tickets table is changing all the time as users are able to add/delete categories.