我的表(tb_ticket)哪像这样:
| 技术人员_1|技术员_2|
| - -|- -|
| 埃马|埃马|
| 汤姆|埃马|
| 丽莎|汤姆|
| 阿那|丽莎|
| 汤姆|汤姆|
我的问题是如何使它变成这样:
艾玛=3,汤姆=4,安娜=1,丽莎=2
我的查询
<script>
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Ema", "Tom", "Ana", "Lisa"],
datasets: [{
label: 'Request by technician',
data: [
<?php
$technician_ema= mysqli_query($koneksi,"select * from tb_ticket where (technician_1','technician_2)='Ema'");
echo mysqli_num_rows($technician_ema);
?>,
<?php
$technician_tom= mysqli_query($koneksi,"select * from tb_ticket where (technician_1','technician_2)='Tom'");
echo mysqli_num_rows($technician_tom);
?>,
<?php
$technician_ana= mysqli_query($koneksi,"select * from tb_ticket where (technician_1','technician_2)='Ana'");
echo mysqli_num_rows($technician_ana);
?>,
<?php
$technician_lisa= mysqli_query($koneksi,"select * from tb_ticket where (technician_1','technician_2)='Lisa'");
echo mysqli_num_rows($technician_lisa);
?>
],
backgroundColor: [
'#1B4F72',
'#21618C',
'#2874A6',
'#2E86C1'
],
}]
},
options: {
scales: {
xAxes: [{
ticks: {
autoSkip: false
}
}]
}
}
});
</script>
将列technician_1和technician_2中的技术人员总数合并到一个条形图中。
My chart like this
1条答案
按热度按时间trnvg8h31#
已解决。更改下面的代码。