MINI
C:
/
xampp
/
htdocs
/
polling_rt
/
Upload File:
files >> C:/xampp/htdocs/polling_rt/result.php
<?php include "config.php"; $q = mysqli_query($conn,"SELECT candidates.name, COUNT(votes.id) AS total FROM candidates LEFT JOIN votes ON candidates.id=votes.candidate_id GROUP BY candidates.id"); $labels=[]; $data=[]; while($d=mysqli_fetch_assoc($q)){ $labels[]=$d['name']; $data[]=$d['total']; } ?> <!DOCTYPE html> <html> <head> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <title>Hasil Voting</title></head><body> <canvas id="hasil" width="400" height="200"></canvas> <script> new Chart(document.getElementById('hasil'),{ type:'bar', data:{ labels: <?= json_encode($labels) ?>, datasets:[{ label: "Perolehan Suara", data: <?= json_encode($data) ?>, }] } }); </script> </body></html>
Copyright ©2021 || Defacer Indonesia