-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_search_getter.php
executable file
·77 lines (66 loc) · 2.67 KB
/
table_search_getter.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
<div id="res_busqueda">
<?php
include_once('dbconnect.php');
if(isset($_POST['player'])){
$namesLike = $_POST['player'];
$result = pg_exec($conn, "SELECT * FROM players
WHERE name ILIKE '%$namesLike%' LIMIT 20");
}
else if(isset($_POST['team'])){
$namesLike = $_POST['team'];
$result = pg_exec($conn, "select * from players where draft_team ilike '%$namesLike%' LIMIT 20");
}else if(isset($_POST['best_uni'])){
$result = pg_exec($conn, "select college as Universidad, round(avg(nflgrade)) as Rank from combine GROUP by college order by rank DESC LIMIT 10");
}else if(isset($_POST['touchdown'])){
$equipo = $_POST['touchdown'];
$sql = "select W.name as Name, W.draft_team as Team, position as Position from players W,(
select E.name as Equipo from shortnames E,(select P.OffenseTeam as Esquipo, sum(P.IsTouchdown) from pbp P,(select siglas from shortnames where name='$equipo') S where P.DefenseTeam=S.siglas Group by P.OffenseTeam order by sum desc limit 1) A where E.siglas=A.Esquipo) k where W.draft_team= k.Equipo and w.year_end=2013";
$result = pg_exec($conn, $sql);
}else if(isset($_POST['order_players'])){
$order = $_POST['order_players'];
$orderBy = $_POST['order_by'];
$limit = $_POST['show'];
$result = pg_exec($conn, "SELECT * FROM players $order $orderBy $limit ");
}
if(pg_numrows($result) > 0){
$row = pg_fetch_array($result, 0);
$num_parametros = sizeof(array_keys($row));
}
//print_r($num_parametros);
if(!$result || pg_numrows($result) <= 0){//no hay datos
?> <span class="">No hay datos</span>
<?php
}else{//hay datos
?>
<table class="table table-striped table-hover">
<tr>
<?php for($i=1; $i <= $num_parametros; $i=$i+2){ ?>
<td>
<?php echo array_keys($row)[$i]; ?>
</td>
<?php
}
?>
</tr>
<?php
$numrows = pg_numrows($result);
for($i=0; $i < $numrows; $i++){
$row = pg_fetch_array($result, $i);
?>
<tr>
<?php
for($j=1; $j <= $num_parametros; $j=$j+2){ ?>
<td>
<?php echo $row[array_keys($row)[$j]]; ?> </td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</div>