-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.php
executable file
·296 lines (248 loc) · 10.4 KB
/
stats.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php
include_once('dbconnect.php');
$equipos = pg_exec($conn, "SELECT name FROM shortnames");
?>
<!DOCTYPE html>
<html>
<head>
<title> Estadisticas </title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="js/jquery-3.2.1.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<style>
body {
background-color: lightgray;
}
nav {
padding-right: 20px;
}
</style>
<script src="js/getAPI.js"></script>
</head>
<body>
<div class="navbar-wrapper">
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">NFL</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav nav-bar-left">
<li><a href="usuarios.php">Usuarios</a></li>
<li><a href="mi_perfil.php">Mi Perfil</a></li>
</ul>
</div>
</div>
</nav>
</div>
<div align="center">
<h2 class="display-4">Estadística</h2>
<h5 class="display-4">Consultas</h5>
<hr>
</div>
<form method="POST" action="stats.php">
<div>
<span class="">Selección de jugadores</span>
</div>
<table class="table table-striped table-hover table-condensed">
<tr>
<td>Ordenar por</td>
<td>De forma</td>
<td>Mostrar</td>
</tr>
<tr>
<td>
<select id="order_players" class="form-control">
<option value="ORDER BY name">Nombre</option>
<option value="ORDER BY birth_date">Fecha de nacimiento</option>
<option value="ORDER BY college">Instituto</option>
<option value="ORDER BY position">Posición</option>
<option value="ORDER BY height">Altura</option>
<option value="ORDER BY weight">Peso</option>
<option value="ORDER BY year_start">Año comienzo</option>
<option value="ORDER BY year_end">Año término</option>
<option value="ORDER BY year_end - year_start">Duración</option>
</select>
</td>
<td>
<select id="order_by" class="form-control">
<option value="ASC">Ascendiente</option>
<option value="DESC">Descendiente</option>
</select>
</td>
<td>
<select id="show_limit" class="form-control">
<option value="LIMIT 10">10</option>
<option value="LIMIT 50">50</option>
<option value="LIMIT 100">100</option>
<option value="">Todo</option>
</select>
</td>
<td><button type="button" id="consultar" class="btn btn-primary btn-sm">Ver Stats </button></td>
</tr>
</table>
<hr>
<div class="row">
<div class="col-xs-5">
<input type="text" id="players" placeholder="Buscar jugador" size="15" class="form-control">
</div>
</div>
<div class="row">
<div class="col-xs-5">
<input type="text" id="team" placeholder="Buscar datos del equipo" size="20" class="form-control">
</div>
</div>
<hr>
<div class="row">
<div class="col-xs-6">
<div class="input-group">
<span class="input-group-addon"> Universidades mejor puntuadas</span>
<span class="input-group-btn"><button type="button" class="btn btn-primary btn-sm" id="uni_mejor_puntuadas" onclick="mejores_univeridades()">Mostrar</button></span>
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-xs-10">
<div class="input-group">
<span class="input-group-addon"> Equipo que más touchdowns le anotó a</span>
<span class="input-group-addon"><select id="touchdown_select" class="form-control">
<?php
for($i=0; $i <pg_numrows($equipos); $i++){
$row = pg_fetch_array($equipos, $i);
?>
<option value="<?php echo $row['name']; ?>"><?php echo $row['name']; ?></option>
<?php
}
?>
</select></span>
<span class="input-group-btn"><button type="button" class="btn btn-primary btn-lg" id="touchdown_button">Mostrar</button></span>
</div>
</div>
</div>
<div id="resultados_busqueda" style="margin-left:120px;padding-left:5px;">
</div>
<br>
</form>
</body>
<script>
function llamar_otra_pagina_Equipo() {
var texto = $('input[name="team"]').val();
var process = function(response) {
$('#resultados_busqueda').html(response);
}
getAPI("<?php echo $base_url; ?>/table_search_getter.php?team=" + texto, process);
}
function predictionsTeam() {
if ($('input[name="team"]').val().length >= 1) {
llamar_otra_pagina_Equipo();
} else {
$('#resultados_busqueda').html('');
}
}
function llamar_otra_pagina_Player() {
var texto = $('input[name="players"]').val();
var process = function(response) {
$('#resultados_busqueda').html(response);
}
getAPI("<?php echo $base_url; ?>/table_search_getter.php?player=" + texto, process);
}
function predictionsPlayer() {
if ($('input[name="players"]').val().length >= 2) {
llamar_otra_pagina_Player();
} else {
$('#resultados_busqueda').html('');
}
}
function mejores_univeridades() {
var texto = "";
var process = function(response) {
$('#resultados_busqueda').html(response);
}
getAPI("<?php echo $base_url; ?>/table_search_getter.php?best_uni=" + texto, process);
}
function mostTouchdowns() {
var texto = document.getElementById("touchdown_select").value;
var process = function(response) {
$('#resultados_busqueda').html(response);
}
getAPI("<?php echo $base_url; ?>/table_search_getter.php?touchdown=" + texto, process);
}
function escapeHtml(text) {
var map = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
return text.replace(/[&<>"']/g, function(m) {
return map[m];
});
}
$(document).ready(function() {
$("#players").keyup(function() {
var valor_enviar = $("#players").val();
$.post("table_search_getter.php", {
player: valor_enviar
},
function(data, status) {
$('#resultados_busqueda').html(data);
});
});
});
$(document).ready(function() {
$("#team").keyup(function() {
var valor_enviar = $("#team").val();
$.post("table_search_getter.php", {
team: valor_enviar
},
function(data, status) {
$('#resultados_busqueda').html(data);
});
});
});
$(document).ready(function() {
$("#touchdown_button").click(function() {
var valor_enviar = document.getElementById("touchdown_select").value;
$.post("table_search_getter.php", {
touchdown: valor_enviar
},
function(data, status) {
$('#resultados_busqueda').html(data);
});
});
});
$(document).ready(function() {
$("#uni_mejor_puntuadas").click(function() {
var valor_enviar = "";
$.post("table_search_getter.php", {
best_uni: valor_enviar
},
function(data, status) {
$('#resultados_busqueda').html(data);
});
});
});
$(document).ready(function() {
$("#consultar").click(function() {
var player = document.getElementById("order_players").value;
var orden = document.getElementById(["order_by"]).value;
var limit = document.getElementById(["show_limit"]).value;
$.post("table_search_getter.php", {
order_players: player,
order_by: orden,
show: limit
},
function(data, status) {
$('#resultados_busqueda').html(data);
});
});
});
</script>
</html>