Repository navigation
Expand file tree
/
Copy pathresult.php
More file actions
47 lines (43 loc) · 1.66 KB
/
Copy pathresult.php
File metadata and controls
47 lines (43 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php require 'extras/header.php';
$today = date('Y-m-d');
$qID = 1;
?>
<script type="text/javascript" src="extras/chart.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
["Option", "Number of votes"],
<?php
// echo "SELECT * FROM questions WHERE QuesID=?";
$rLDate = $conn->prepare("SELECT * FROM questions WHERE QuesID=?");
$rLDate->execute([$qID]);
$dLDate = $rLDate->fetch(PDO::FETCH_ASSOC);
// echo $dLDate->endDate;
$q = "SELECT DISTINCT Opted, COUNT(Opted) AS Num FROM answers WHERE QuesID=? GROUP BY Opted";
$p = $conn->prepare($q);
$p->execute([$qID]);
while($d=$p->fetch(PDO::FETCH_ASSOC)){
echo "['".$d["Opted"]."', ".$d["Num"]."],";
}
?>
]);
var options = {
title: 'Result',
is3D: true,
};
var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
chart.draw(data, options);
}
</script>
<body>
<?php
// echo $today.' '.$dLDate['endDate'];
if(strtotime($dLDate['endDate'])<=strtotime($today)){
echo '<div id="piechart_3d" style="width: 900px; height: 900px;margin: 0 auto;"></div>';
}else echo '<script>alert("Wait for Last Date!")</script>';
?>
<?php require 'extras/footer.php'; ?>
</body>
</html>