-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathestadisticas.php
223 lines (156 loc) · 5.12 KB
/
estadisticas.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
include 'services/checkLogin.php';
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Almacenamiento de Votos - Agora US</title>
<!-- Bootstrap Core CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
<!-- Custom Fonts -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css" type="text/css">
<!-- Plugin CSS -->
<link rel="stylesheet" href="css/animate.min.css" type="text/css">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/creative.css" type="text/css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body id="page-top">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<div id="styleHeadEstadisticas" >
<ul class="nav navbar-nav navbar-right">
<li>
<a class="page-scroll" href="index.php">ALMACENAMIENTO DE VOTOS</a>
</li>
</ul>
</div>
</div>
<section class="bg-primary" id="stadistics">
<div class="col-lg-8 col-lg-offset-2 text-center">
<h2 class="section-heading">Estadísticas</h2>
<hr class="light">
<p>Aquí podrá ver distintos datos sobre el contenido de la base de datos</p>
</div>
<hr/>
</section>
<?php if($isLogged==true){ ?>
<p align="center">VOTACIONES POR ENCUESTA</p>
<table class="table table-hover">
<tr>
<td id="titleColumn"><b>Total de Votaciones</b></td>
<td id="titleColumn"><b>Id de la Votación</b></td>
</tr>
<?php
include 'config.php';
$link = new mysqli($servername,$username, $pass, $dbname);
$sql = "SELECT COUNT(*),id_poll FROM Votes group by id_poll";
$result = $link ->query($sql);
$cont=0;
while($row = $result->fetch_assoc()){
foreach ($row as $value) {
if($cont%2==0 || $cont==0){
echo "<tr><td>" . $value . "</td>";
} else{
echo "<td>".$value . "</td>";
}
$cont ++;
}
}
$cont=0;
$link->close();
?>
</table>
<p align="center">TOTAL DE VOTOS REGISTRADOS</p>
<table class="table table-hover">
<tr>
<td id="titleColumn"><b>Total de Votos</b></td>
</tr>
<?php
include 'config.php';
$link = new mysqli($servername,$username, $pass, $dbname);
$sql = "SELECT COUNT(*) FROM Votes";
$result = $link ->query($sql);
$row=$result->fetch_assoc();
$i=($row["COUNT(*)"]);
echo "<tr><td>" . $i . "</td>";
$link->close();
?>
</table>
<p align="center">VOTACIONES POR EDAD</p>
<table class="table table-hover">
<tr>
<td id="titleColumn"><b>Votos por Edad</b></td>
<td id="titleColumn"><b>Edad</b></td>
</tr>
<?php
include 'config.php';
$link = new mysqli($servername,$username, $pass, $dbname);
$sql = "SELECT COUNT(*),age FROM Votes GROUP BY age";
$result = $link ->query($sql);
$cont=0;
while($row = $result->fetch_assoc()){
foreach ($row as $value) {
if($cont%2==0 || $cont==0){
echo "<tr><td>" . $value . "</td>";
} else{
echo "<td>".$value . "</td>";
}
$cont ++;
}
}
$cont=0;
$link->close();
?>
</table>
<table class="table table-hover">
<tr>
<td id="titleColumn"><b>Votos por Comunidad</b></td>
<td id="titleColumn"><b>Comunidad</b></td>
</tr>
<?php
include 'config.php';
$link = new mysqli($servername,$username, $pass, $dbname);
$sql = "SELECT COUNT(*),comunity FROM Votes group by comunity";
$result = $link ->query($sql);
$cont=0;
while($row = $result->fetch_assoc()){
foreach ($row as $value) {
if($cont%2==0 || $cont==0){
echo "<tr><td>" . $value . "</td>";
} else{
echo "<td>".$value . "</td>";
}
$cont ++;
}
}
$cont=0;
$link->close();
?>
</table>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Plugin JavaScript -->
<script src="js/jquery.easing.min.js"></script>
<script src="js/jquery.fittext.js"></script>
<script src="js/wow.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/creative.js"></script>
<?php }else{ ?>
<a>Debe loguearse para acceder a esta página</a>
<?php } ?>
</body>
</html>