Mineplex2018-withcommit/Webpages/leaderboard.php
2014-09-07 18:09:46 -04:00

125 lines
3.6 KiB
PHP

<!DOCTYPE html>
<html>
<head>
<title>The Fall Invitational Leaderboard</title>
<meta http-equiv="refresh" content="30">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style type="text/css">
.table td.center, .table th.center {
text-align: center;
}
.panel-heading {
text-align: center;
font-size: 18pt;
font-weight: bold;
color: orange!important;
background-color: #333!important;
border-color: #333!important;
}
.panel-primary {
border-color: #333!important;
}
</style>
</head>
<body>
<div class="jumbotron" style="text-align: center">
<div class="container" style="text-align: center">
<img src="mineplex.png" alt="Mineplex"/>
<h1>The Fall Invitational</h1>
<h2>Tournament Leaderboard</h2>
</div>
</div>
<hr/>
<div class="container-fluid">
<div class="row">
<?php
$tournamentTypes = array('Super Smash Mobs', 'Survival Games', 'Mixed Arcade');
$con = mysqli_connect('db.mineplex.com', 'root', 'tAbechAk3wR7tuTh', 'Account');
for ($i = 0; $i < count($tournamentTypes); $i++)
{
?>
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading"><?php echo $tournamentTypes[$i] ?></div>
<div class="table-responsive">
<table class="table">
<col style="width: 15%">
<col style="width: 40%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
<tr>
<th class="center">Rank</th>
<th>Player</th>
<th class="center">Wins</th>
<th class="center">Losses</th>
<th class="center">Score*</th>
</tr>
<?php
$query = <<<QUERY
SELECT name, wins, total, score
FROM tournamentLeaderboard
JOIN accounts ON accounts.id = accountId
WHERE tournamentId = 0
AND gameId = $i
AND score IS NOT NULL
ORDER BY score DESC, name ASC
LIMIT 50;
QUERY;
$result = mysqli_query($con, $query);
$index = 1;
$rank = 1;
$lastScore = null;
while($row = mysqli_fetch_array($result))
{
$score = $row['score'];
if ($score != $lastScore)
{
$rank = $index;
}
?>
<tr>
<td class="center"><?php echo $rank ?></td>
<td><?php echo $row['name'] ?></td>
<td class="center"><?php echo $row['wins'] ?></td>
<td class="center"><?php echo ($row['total'] - $row['wins']) ?></td>
<td class="center"><?php echo round($score*100, 3) ?></td>
</tr>
<?php
$index++;
$lastScore = $score;
}
?>
</table>
</div>
</div>
</div>
<?php
}
mysqli_close($con);
?>
</div>
</div>
<p style="text-align: center; font-style: italic">*Score = 100 &times; Wins &times; (Wins / Total)<sup>3</sup></p>
<hr/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>