Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
Combine multiple columns values to one label in chart.js

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.

My chart like this

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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);
?>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!