-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverview.php
191 lines (127 loc) · 6 KB
/
overview.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
session_start();
include('./connect/connect.php');
if (!isset($_SESSION['username'])) {
header('location: ./index.php');
}
$check5 = "SELECT * FROM users WHERE id = " . $_SESSION['id'];
$m5 = mysqli_query($conn, $check5);
if (mysqli_num_rows($m5) == 1) {
$num = mysqli_fetch_array($m5);
$point = $num['point'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<?php include('./component/link.php') ?>
</head>
<body>
<?php include('./component/sidebar.php') ?>
<div class="page">
<div class="page__wrapper">
<?php include('./component/header.php') ?>
<div style="margin: 80px 60px 60px 60px">
<h1 style="font-weight:700;color:white" align="left">ภาพรวมการเลือก</h1>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div class="container pt-5 pb-5" style="background: white;border-radius:10px;margin-top:30px;padding:0rem 3rem 0rem 3rem;box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;">
<div class="d-none d-md-block d-lg-block d-xl-block d-xxl-block">
<h5>
จำนวนนักเรียนที่มีสิทธิ์โหวต
<?php
$sql = "SELECT id FROM users WHERE point = '1' ";
$query = mysqli_query($conn, $sql);
echo mysqli_num_rows($query);
?>
คน
</h5>
<h5 class="pb-4">
มีนักเรียนที่โหวตแล้ว
<?php
$sql = "SELECT id FROM users WHERE point = '0' ";
$query = mysqli_query($conn, $sql);
$sql1 = "SELECT id FROM users ";
$query1 = mysqli_query($conn, $sql1);
$percent = (mysqli_num_rows($query) / mysqli_num_rows($query1)) * 100;
echo mysqli_num_rows($query);
?>
คน
<span style="color:#d91b5c">
คิดเป็นร้อยละ <?php echo round($percent, 2) ?>
</span>
</h5>
<h5 align="center">แผนภูมิแท่งแสดงจำนวนการลงคะแนนของแต่ละห้อง</h5>
</div>
<div class="d-md-none d-lg-none d-xl-none d-xxl-none">
<p>
จำนวนนักเรียนที่มีสิทธิ์โหวต
<?php
$sql = "SELECT id FROM users WHERE point = '1' ";
$query = mysqli_query($conn, $sql);
echo mysqli_num_rows($query);
?>
คน
</p>
<p class="pb-4">
มีนักเรียนที่โหวตแล้ว
<?php
$sql = "SELECT id FROM users WHERE point = '0' ";
$query = mysqli_query($conn, $sql);
$sql1 = "SELECT id FROM users ";
$query1 = mysqli_query($conn, $sql1);
$percent = (mysqli_num_rows($query) / mysqli_num_rows($query1)) * 100;
echo mysqli_num_rows($query);
?>
คน
<span style="color:#d91b5c">
คิดเป็นร้อยละ <?php echo round($percent, 2) ?>
</span>
</p>
<p align="center">แผนภูมิแท่งแสดงจำนวนการลงคะแนนของแต่ละห้อง</p>
</div>
<div id="chart_div" class=""></div>
</div>
</div>
</div>
</div>
</div>
<?php
$query22 = "SELECT room, count(*) as point FROM users WHERE point = '0' GROUP BY room ORDER BY room ASC";
$result22 = mysqli_query($conn, $query22);
?>
<?php include('./component/linkjs.php') ?>
<script type="text/javascript">
google.charts.load('current', {
packages: ['corechart', 'bar']
});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'จำนวนผู้โหวต');
data.addColumn('number', 'จำนวนผู้โหวต');
data.addRows([
<?php
while ($row22 = mysqli_fetch_array($result22)) {
echo "['ม.1/" . $row22["room"] . "', " . $row22["point"] . " ],";
}
?>
]);
var options = {
hAxis: {
title: 'นักเรียนที่มาโหวต',
fontSize: 100,
},
};
var chart = new google.visualization.ColumnChart(
document.getElementById('chart_div'));
chart.draw(data, options);
}
$(window).resize(function() {
drawBasic();
});
</script>
</body>
</html>