1๐
โ
<script>
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['Body Pump', 'Spin Class', 'Yoga', 'Body Tone', 'Legs, Bums & Tums'],
datasets: [{
label: 'Total Number of Bookings',
data: [
<?php
$querybodypump = "SELECT COUNT(SessionType) FROM bookings WHERE username = '".$_SESSION['username']."' AND SessionType = 'bodyPump'";
$resultbodypump = mysqli_query($db,$querybodypump);
$row1 = mysqli_fetch_row($resultbodypump);
$count1 = $row1[0];
$queryspinclass = "SELECT COUNT(SessionType) FROM bookings WHERE username = '".$_SESSION['username']."' AND SessionType = 'spinClass'";
$resultspinclass = mysqli_query($db,$queryspinclass);
$row2 = mysqli_fetch_row($resultspinclass);
$count2 = $row2[0];
$queryyoga = "SELECT COUNT(SessionType) FROM bookings WHERE username = '".$_SESSION['username']."' AND SessionType = 'yoga'";
$resultyoga = mysqli_query($db,$queryyoga);
$row3 = mysqli_fetch_row($resultyoga);
$count3 = $row3[0];
$querybodytone = "SELECT COUNT(SessionType) FROM bookings WHERE username = '".$_SESSION['username']."' AND SessionType = 'bodyTone'";
$resultbodytone = mysqli_query($db,$querybodytone);
$row4 = mysqli_fetch_row($resultbodytone);
$count4 = $row4[0];
$querylegsbumstums = "SELECT COUNT(SessionType) FROM bookings WHERE username = '".$_SESSION['username']."' AND SessionType = 'legsBumsTums'";
$resultlegsbumstums = mysqli_query($db,$querylegsbumstums);
$row5 = mysqli_fetch_row($resultlegsbumstums);
$count5 = $row5[0];
echo $count1. ",";
echo $count2 . ",";
echo $count3 . ",";
echo $count4 . ",";
echo $count5 ;
?>
],
Source:stackexchange.com