-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.php
229 lines (178 loc) · 10.4 KB
/
report.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
<?php
include_once 'parts/header.php';
?>
<section id="basketball">
<div class="container">
<h1>
<?php
if( isset( $_GET["game"] ) ){
echo $_GET["game"];
}
?>
</h1>
<div class="tabs-wrapper">
<ul class="tabs">
<li class="tab active" data-detail="teams">Teams</li>
<li class="tab" data-detail="fixture">Fixture</li>
<li class="tab" data-detail="result">Results</li>
</ul>
<div class="table-report show" data-detail="teams">
<ul class="table flat">
<li class="table-list">
<table cellspacing=0>
<thead>
<tr>
<th>Updated: <?php echo date('d/m/Y h:i:s A') ?></th>
<th>P</th>
<th>W</th>
<th>D</th>
<th>L</th>
<th>Pts</th>
</tr>
</thead>
<tbody>
<?php
if( isset( $_GET["game"] ) ){
$event_name = $_GET['event'];
$game_name = $_GET["game"];
$sql = $connection->prepare("SELECT * FROM teams WHERE team_game=:name AND team_event=:event");
$sql->execute( array( ':name' => $game_name, ':event' => $event_name ) );
$data = [];
$idx = 0;
while( $row = $sql->fetch() ){
$team_name = $row['team_name'];
$players = $row['players'];
$win = $row['win'];
$draw = $row['draw'];
$lost = $row['lost'];
$points = $row['points'];
$data[] = array(
'team_name' => $team_name,
'players' => $players,
'win' => $win,
'draw' => $draw,
'lost' => $lost,
'points' => $points
);
}
for( $j = 0; $j < count( $data ); $j++ ){
for( $i = 0; $i < count( $data ) - $j - 1; $i++ ){
if( $data[$i]['points'] < $data[$i+1]['points'] ){
$temp = $data[$i];
$data[$i] = $data[$i+1];
$data[$i+1] = $temp;
}
}
}
foreach( $data as $row ){
$idx++;
$team_name = $row['team_name'];
$players = $row['players'];
$win = $row['win'];
$draw = $row['draw'];
$lost = $row['lost'];
$points = $row['points']; ?>
<tr>
<td><span class="idx"><?php echo $idx; ?></span><?php echo $team_name ?></td>
<td><?php echo $players ?></td>
<td><?php echo $win ?></td>
<td><?php echo $draw ?></td>
<td><?php echo $lost ?></td>
<td><?php echo $points ?></td>
</tr>
<?php }
}
?>
</tbody>
</table>
</li>
</ul>
</div>
<div class="table-report" data-detail="fixture">
<?php
$events = $_GET['event'];
$games = $_GET['game'];
$sql = $connection->prepare( "SELECT * FROM teams WHERE team_event=:events AND team_game=:game" );
$sql->execute(array(':events'=>$events, ':game' => $games));
$teams = [];
while( $row = $sql->fetch() ){
$team_name = $row['team_name'];
$teams[] = $team_name;
}
$teams_db = [];
foreach( $teams as $team ){
$sql = $connection->prepare( "SELECT * FROM fixture WHERE team_a=:team_a OR team_b=:team_a" );
$sql->execute( array( ':team_a' => $team ) );
while( $row = $sql->fetch() ){
$teams_db[] = $row;
}
}
$teams_unique = makeUnique( $teams_db);
foreach( $teams_unique as $t ){ ?>
<ul class="table flat border-bottom">
<li class="table-list">
<div class="fixture-table">
<div class="team-1">
<h2><?php echo $t[1] ?></h2>
</div>
<div class="details">
<p class="date"><?php echo $t[3] ?></p>
<p class="time"><?php echo $t[4] ?></p>
<h3><?php echo $t[5] ?></h3>
</div>
<div class="team-2">
<h2><?php echo $t[2] ?></h2>
</div>
</div>
</li>
</ul>
<?php }
?>
</div>
<div class="table-report" data-detail="result">
<?php
$events = $_GET['event'];
$games = $_GET['game'];
$sql = $connection->prepare( "SELECT * FROM teams WHERE team_event=:events AND team_game=:game" );
$sql->execute(array(':events'=>$events, ':game' => $games));
$teams = [];
while( $row = $sql->fetch() ){
$team_name = $row['team_name'];
$teams[] = $team_name;
}
$teams_db = [];
foreach( $teams as $team ){
$sql = $connection->prepare( "SELECT * FROM results WHERE team_a=:team_a OR team_b=:team_a" );
$sql->execute( array( ':team_a' => $team ) );
while( $row = $sql->fetch() ){
$teams_db[] = $row;
}
}
$teams_unique = makeUnique( $teams_db);
foreach( $teams_unique as $t ){ ?>
<ul class="table flat border-bottom">
<li class="table-list">
<div class="fixture-table">
<div class="team-1">
<h2><?php echo $t[1] ?></h2>
</div>
<div class="details">
<p class="date"><?php echo $t[5] ?></p>
<p class="result"><?php echo $t[3] ?>-<?php echo $t[4] ?></p>
<h3><?php echo $t[6] ?></h3>
</div>
<div class="team-2">
<h2><?php echo $t[2] ?></h2>
</div>
</div>
</li>
</ul>
<?php }
?>
</div>
</div>
</div>
</section>
<script src="js/report.js"></script>
</body>
</html>