-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResults.php
194 lines (152 loc) · 4.87 KB
/
Results.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
192
193
194
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Table</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
body {
padding: 0px;
margin: 0;
font-family: Verdana, Geneva, Tahoma, sans-serif;
}
table {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-collapse: collapse;
width: 800px;
height: 200px;
border: 1px solid #fb4242;
box-shadow: box-shadow: 20px 20px 4px 0 rgba(176, 224, 230, .4);
}
tr {
transition: all .2s ease-in;
cursor: pointer;
}
th,
td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
#header {
background-color: #fb4242;
color: #fff;
}
h1 {
font-weight: 600;
text-align: center;
background-color: #fb4242;
color: #fff;
padding: 10px 0px;
}
tr:hover {
background-color: #f5f5f5;
transform: scale(1.02);
box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.2), -1px -1px 8px rgba(0, 0, 0, 0.2);
}
@media only screen and (max-width: 768px) {
table {
width: 90%;
}
}
</style>
<body>
<h1>Survey Results</h1>
<hr>
<?php
error_reporting(0);
$conn = mysqli_connect("localhost","root","","phptutorials") or die (mysqli_error());
$query = "SELECT COUNT(*) AS count FROM demo";
$query_result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($query_result)){
$output ="".$row['count'];
}
$que = "SELECT ROUND(AVG(Age)) AS avg FROM demo";
$query_results = mysqli_query($conn, $que);
while ($row = mysqli_fetch_assoc($query_results)){
$outputs ="".$row['avg'];
}
$quer = "SELECT MAX(Age)AS max FROM demo";
$query_resul = mysqli_query($conn, $quer);
while ($row = mysqli_fetch_assoc($query_resul)){
$outpu ="".$row['max'];
}
$qu = "SELECT MIN(Age) AS min FROM demo";
$query_resu = mysqli_query($conn, $qu);
while ($row = mysqli_fetch_assoc($query_resu)){
$outp ="".$row['min'];
}
$gh = "SELECT food , COUNT(*)/$output*100 AS pizza FROM `demo` WHERE food = 'Pizza,'GROUP BY food";
$keef = mysqli_query($conn, $gh);
while ($row = mysqli_fetch_assoc($keef)){
$che="".ROUND($row['pizza']);
}
$ry = "SELECT food , COUNT(*)/$output*100 AS pasta FROM `demo` WHERE food = 'Pasta,'GROUP BY food";
$query_ = mysqli_query($conn, $ry);
while ($row = mysqli_fetch_assoc($query_)){
$o="".ROUND($row['pasta']);
}
$uq = "SELECT food , COUNT(*)/$output*100 AS pap FROM `demo` WHERE food = 'PapnWors,'GROUP BY food";
$rsu = mysqli_query($conn, $uq);
while ($row = mysqli_fetch_assoc($rsu)){
$u="".ROUND($row['pap']);
}
$q = "SELECT ROUND(AVG(Eat)) AS eat FROM demo";
$query_res = mysqli_query($conn, $q);
while ($row = mysqli_fetch_assoc($query_res)){
$out="".$row['eat'];
}
$ue = "SELECT ROUND(AVG(Movies)) AS movies FROM demo";
$query_re = mysqli_query($conn, $ue);
while ($row = mysqli_fetch_assoc($query_re)){
$puts ="".$row['movies'];
}
$Q = "SELECT ROUND(AVG(TV)) AS tv FROM demo";
$query_r = mysqli_query($conn, $Q);
while ($row = mysqli_fetch_assoc($query_r)){
$put ="".$row['tv'];
}
$ques = "SELECT ROUND(AVG(Radio)) AS radio FROM demo";
$query_Q = mysqli_query($conn, $ques);
while ($row = mysqli_fetch_assoc($query_Q)){
$outs ="".$row['radio'];
}
echo " <table>
<tr id='header'>
<th>Total Number Of Surveys</th>
<th>Average Age</th>
<th>Maximum Age</th>
<th>Minimum Age</th>
<th>% Of People who like Pizza</th>
<th>% Of People who like Pasta</th>
<th>% Of People who like Pap and Wors</th>
<th>People who Eat Out</th>
<th>People who watch Movies</th>
<th>People who watch TV</th>
<th>People who listen to Radio</th>
</tr>
<tr>
<td>$output </td>
<td>$outputs </td>
<td>$outpu </td>
<td>$outp </td>
<td>$che </td>
<td>$o </td>
<td> $u </td>
<td>$out </td>
<td>$puts </td>
<td>$put </td>
<td>$outs </td>
</tr>
<div class='form-group mb-3'>
<a href='index.php'><button class='btn btn-primary'>OK</button>
</div>
</table><br></br>";
?>
</body>
</html>