-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow.php
411 lines (378 loc) · 18.7 KB
/
show.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<?php
header('Content-Type:text/html;charset=utf-8');
$check = $_POST;
if ($check) {
$button = $_POST["submit"];
if ($button == "登出") {
session_start();
if (isset($_POST['submit'])) {
unset($_SESSION['accout']);
}
if (!isset($_SESSION['accout'])) {
header("Location: login.php");
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>顯示資料</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Pragma" Content="No-cache">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
@import url(https://fonts.googleapis.com/earlyaccess/cwtexfangsong.css);
body {
font-family: "cwTeXFangSong";
font-size: 25px;
width: 100%;
height: 100vh;
margin: 0;
padding: 0;
background-color: rgb(205, 202, 202);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
table table {
width: 100%;
margin: 15px 0;
border: 0;
}
table th {
font-weight: bold;
background-color: #B8B8DC;
color: #5151A2
}
table,
table th,
table td {
font-size: 0.95em;
text-align: center;
padding: 4px;
border-collapse: collapse;
}
table th {
border: 2px solid #484891;
border-width: 2px
}
table td {
border: 2px solid #484891;
border-width: 2px
}
table tr {
border: 1px solid #ffffff;
}
table tr:nth-child(odd) {
background-color: #A6A6D2;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
</style>
</head>
<body>
<div class="jumbotron text-center" style="margin-bottom:0">
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-2">
<a href="home.php">
<button type="button" class="button1">
<span class="glyphicon glyphicon-home"></span> 首頁
</button>
</a>
</div>
<div class="col-sm-6">
<h1>顯示資料</h1>
</div>
<div class="col-sm-2">
<form method='post'>
<input type='submit' name='submit' value='登出' />
</form>
</div>
<div class="col-sm-1"></div>
</div>
</div>
<div class="container" style="margin-top:30px">
<form action="show.php" method="post">
<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-2">顯示哪種表格:</div>
<div class="col-sm-6">
<select name="que" id="que">
<option value="region">全部遊戲的賽區</option>
<option value="contest">全部遊戲的賽程</option>
<option value="team">全部遊戲的隊伍資訊</option>
<option value="team_onlywin">有獲勝的全部遊戲的隊伍資訊</option>
<option value="player">全部遊戲的選手資訊</option>
<option value="counter_team_cnt">每個國家有的隊伍數</option>
<option value="location_player">選擇隊伍所在地並列出選手</option>
<option value="location_win">選擇隊伍所在地並為勝利方的資訊</option>
</select>
<input type="submit" name="submit" value="查詢">
<script type="text/javascript">
document.getElementById('que').value = "<?php echo $_POST['que']; ?>";
</script>
</div>
<div class="col-sm-2"></div>
</div>
<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-2"></div>
<div class="col-sm-6">
<?php
include_once "team18_database.php";
$check = $_POST;
if ($check) {
$que = $_POST['que'];
if ($que == "location_player" || $que == "location_win") {
$query = ("select distinct location from team_info");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
echo "國家:<select name='data' id='data'>";
for ($i = 0; $i < count($result); $i++) {
echo "<option value='" . $result[$i]['location'] . "'>" . $result[$i]['location'] . "</option>";
}
echo "</select>";
echo "<input type='submit' name='submit' value='確認'>";
}
}
?>
<script type="text/javascript">
document.getElementById('data').value = "<?php echo $_POST['data']; ?>";
</script>
</div>
<div class="col-sm-2"></div>
</div>
</form>
<div class="row">
<div class="col-sm-2"></div>
<div class="col-sm-8">
<?php
//header("Content-type:text/html;charset=utf-8");
include_once "team18_database.php";
$check = $_POST;
if ($check) {
$button = $_POST["submit"];
if ($button == "查詢") {
$que = $_POST['que'];
if ($que == "region") {
echo "<table>";
echo "<tr>";
echo "<th>遊戲名稱</th>";
echo "<th>賽區</th>";
echo "<th>賽季</th>";
echo "<th>開始日期</th>";
echo "<th>結束日期</th>";
echo "</tr>";
$query = ("select * from region_name");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['game_name'] . "</td>";
echo "<td>" . $result[$i]['region'] . "</td>";
echo "<td>" . $result[$i]['season'] . "</td>";
echo "<td>" . $result[$i]['begin_month'] . "/" . $result[$i]['begin_date'] . "</td>";
echo "<td>" . $result[$i]['end_month'] . "/" . $result[$i]['end_date'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else if ($que == "contest") {
echo "<table>";
echo "<tr>";
echo "<th>遊戲名稱</th>";
echo "<th>賽區</th>";
echo "<th>比賽時間</th>";
echo "<th>隊伍1</th>";
echo "<th>隊伍2</th>";
echo "<th>獲勝隊伍</th>";
echo "</tr>";
$query = ("SELECT * FROM contest");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['game_name'] . "</td>";
echo "<td>" . $result[$i]['region'] . "</td>";
echo "<td>" . $result[$i]['month'] . "/" . $result[$i]['date'] . " " . $result[$i]['time'] . "</td>";
echo "<td>" . $result[$i]['team1'] . "</td>";
echo "<td>" . $result[$i]['team2'] . "</td>";
echo "<td>" . $result[$i]['win_team'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else if ($que == "team") {
echo "<table>";
echo "<tr>";
echo "<th>遊戲名稱</th>";
echo "<th>隊伍名稱</th>";
echo "<th>隊伍所在國家</th>";
echo "<th>勝場數</th>";
echo "</tr>";
$query = ("SELECT game_name, team,location,win_cnt(team,team_info.game_name) as wincnt
FROM team_info
WHERE 1");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['game_name'] . "</td>";
echo "<td>" . $result[$i]['team'] . "</td>";
echo "<td>" . $result[$i]['location'] . "</td>";
echo "<td>" . $result[$i]['wincnt'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else if ($que == "team_onlywin") {
echo "<table>";
echo "<tr>";
echo "<th>遊戲名稱</th>";
echo "<th>隊伍名稱</th>";
echo "<th>隊伍所在國家</th>";
echo "<th>勝場數</th>";
echo "</tr>";
$query = ("SELECT team_info.game_name, team,location,win_cnt(team,team_info.game_name) as wincnt
FROM team_info,contest
WHERE team_info.team = contest.win_team and team_info.game_name = contest.game_name");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['game_name'] . "</td>";
echo "<td>" . $result[$i]['team'] . "</td>";
echo "<td>" . $result[$i]['location'] . "</td>";
echo "<td>" . $result[$i]['wincnt'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else if ($que == "player") {
echo "<table>";
echo "<tr>";
echo "<th>選手</th>";
echo "<th>國家</th>";
echo "<th>隊伍</th>";
echo "<th>遊戲名稱</th>";
echo "</tr>";
$query = ("SELECT * FROM player");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['name'] . "</td>";
echo "<td>" . $result[$i]['country'] . "</td>";
echo "<td>" . $result[$i]['team'] . "</td>";
echo "<td>" . $result[$i]['game_name'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else if ($que == "counter_team_cnt") {
echo "<table>";
echo "<tr>";
echo "<th>國家</th>";
echo "<th>隊伍數</th>";
echo "</tr>";
$query = ("SELECT team_info.location,COUNT(DISTINCT team) as teams
FROM team_info
GROUP BY team_info.location");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['location'] . "</td>";
echo "<td>" . $result[$i]['teams'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
}
}
?>
<?php
include_once "team18_database.php";
$check = $_POST;
if ($check) {
$button = $_POST["submit"];
if ($button == "確認") {
$que = $_POST['que'];
if ($que == "location_player") {
$data = $_POST['data'];
echo "<table>";
echo "<tr>";
echo "<th>遊戲名稱</th>";
echo "<th>選手名稱</th>";
echo "<th>選手國籍</th>";
echo "<th>選手隊伍</th>";
echo "</tr>";
$query = ("select *
from player
where team in (select team from team_info where location = '" . $data . "')");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['game_name'] . "</td>";
echo "<td>" . $result[$i]['name'] . "</td>";
echo "<td>" . $result[$i]['country'] . "</td>";
echo "<td>" . $result[$i]['team'] . "</td>";
echo "</tr>";
}
echo "</table>";
} else if ($que == "location_win") {
$data = $_POST['data'];
echo "<table>";
echo "<tr>";
echo "<th>遊戲名稱</th>";
echo "<th>賽區</th>";
echo "<th>比賽時間</th>";
echo "<th>隊伍1</th>";
echo "<th>隊伍2</th>";
echo "<th>勝利隊伍</th>";
echo "</tr>";
$query = ("select contest.game_name,contest.region,contest.month,contest.date,contest.time,contest.team1,contest.team2,contest.win_team
from (select team from team_info where location = '" . $data . "') as _team , contest
where contest.win_team = _team.team");
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
for ($i = 0; $i < count($result); $i++) {
echo "<tr>";
echo "<td>" . $result[$i]['game_name'] . "</td>";
echo "<td>" . $result[$i]['region'] . "</td>";
echo "<td>" . $result[$i]['month'] . "/" . $result[$i]['date'] . " " . $result[$i]['time'] . "</td>";
echo "<td>" . $result[$i]['team1'] . "</td>";
echo "<td>" . $result[$i]['team2'] . "</td>";
echo "<td>" . $result[$i]['win_team'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
}
}
?>
</div>
<div class="col-sm-2"></div>
</div>
</div>
</body>
</html>