-
Notifications
You must be signed in to change notification settings - Fork 0
/
tournamentsPage.php
83 lines (70 loc) · 2.84 KB
/
tournamentsPage.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
<?php
class tournaments {
function run($parent) {
$db = $parent->db;
//Initiate arrays of signup info
$games = array();
$teams = array();
$signups = array();
//Read games into array of objects
$res = $db->query("SELECT * FROM `games`");
while ($game = mysql_fetch_object($res))
$games[$game->id] = $game;
$parent->displayHeader();
foreach ($games as $game) {
?>
<div class="tournamentGame">
<h1><?php echo $game->game; ?></h1>
<h2><b>Type:</b> <?php echo $game->type; ?></h2>
<h2><b>Time:</b> <?php echo $game->time; ?></h2>
<?php if ($game->teamsize > 0) echo '<h2><b>Teamsize:</b> ' . $game->teamsize . '</h2>'; ?>
<h2 style="margin-left: 2px"><b>Info: </b><?php echo $game->info . "</h2>";
//Team game
if ($game->teamsize > 0) {
//Loop through all teams and list their info
$teams = $db->query("SELECT * FROM `teams` WHERE gameid='%s'", $game->id);
while ($team = mysql_fetch_object($teams)) {
echo '<table class="teamTable">';
echo '<tr><td colspan=4 class="headTd">'.$team->teamname.'</td></tr>';
$members = $db->query("SELECT * FROM `signups` WHERE teamid='%s'", $team->id);
$i = 1;
while ($member = mysql_fetch_object($members)) {
$user = $db->getUser($member->userid);
echo sprintf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $i, $user->name, $user->steamid, $user->seat);
$i++;
}
echo '</table>';
}
//List the randomers team if it exists
$members = $db->query("SELECT * FROM `signups` WHERE teamid IS NULL AND gameid='%s'", $game->id);
if (mysql_num_rows($members) > 0) {
echo '<table class="teamTable">';
echo '<tr><td colspan=4 class="headTd">Randomers</td></tr>';
while ($member = mysql_fetch_object($members)) {
$user = $db->getUser($member->userid);
echo sprintf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $user->id, $user->name, $user->steamid, $user->seat);
}
echo '</table>';
}
}
//Solo game
else {
$members = $db->query("SELECT * FROM `signups` WHERE gameid='%s'", $game->id);
if (mysql_num_rows($members) > 0) {
echo '<table class="teamTable">';
echo '<tr><td colspan=4 class="headTd">'.$game->game.'</td></tr>';
$i = 1;
while ($member = mysql_fetch_object($members)) {
$user = $db->getUser($member->userid);
echo sprintf('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $i, $user->name, $user->steamid, $user->seat);
$i++;
}
echo '</table>';
}
}
echo "</div>";
}
$parent->displayFooter();
}
}
?>