I want to count the number of mechanics in a chart, but some data has multiple data which I use with implode (comma). how to separate data?
I'm taking data from one of my tables, where a column has a value that is implode. the problem here, I just want to explode **nama_tmp **(EKO PAMBUDI, MURNO, ARDI PRASETYO) separately so I can count each name.
The following query I use to display the table:
var chart4;
$(document).ready(function() {
chart4 = new Highcharts.Chart({
chart: {
renderTo: 'mygraph4',
type: 'column'
},
title: {
text: 'Grafik Mekanik'
},
xAxis: {
categories: ['Mekanik']
},
yAxis: {
title: {
text: 'Total Perbaikan'
}
},
series:
[
<?php
include "system/koneksi.php";
$sql = "SELECT nama_tmp FROM tb_tmp GROUP by nama_tmp";
$query = mysqli_query($connect, $sql) or die(mysqli_error());
while($temp = mysqli_fetch_array($query))
{
$namatmp=$temp['nama_tmp'];
$sql_total = "SELECT COUNT(nama_tmp) as 'total' from tb_tmp GROUP by nama_tmp = '$namatmp'";
$query_total = mysqli_query($connect,$sql_total) or die(mysql_error());
while($data = mysqli_fetch_array( $query_total))
{
$total = $data['total'];
}
?>
{
name: '<?php echo $namatmp; ?>',
data: [<?php echo $total; ?>]
},
<?php
} ?>
]
});
});