My table(tb_ticket) which like this :
| technician_1 | Technician_2 |
|---|---|
| Ema | Ema |
| Tom | Ema |
| Lisa | Tom |
| Ana | Lisa |
| Tom | Tom |
My question is how to make it like this :
Ema=3, Tom=4, Ana=1, Lisa=2
My query
<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>
Combine the total number of technicians from column technician_1 and technicians_2 into a bar chart.
Solved. change the code below.
<?php
$technician_lisa= mysqli_query($koneksi,"select * from tb_ticket where technician_1='lisa' or technician_2='Lisa'");
echo mysqli_num_rows($technician_lisa);
?>