This repository has been archived by the owner on May 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highscore.php
69 lines (54 loc) · 1.49 KB
/
highscore.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
<?php require_once('dbconnect.php');?>
<?php
function get_all_from_highscores()
{
try
{
global $db;
$query = "SELECT * FROM highscore";
$ps = $db->prepare($query);
$ps->execute();
}
catch (Exception $e)
{
echo $e->getMessage();
}
return $ps->fetchAll(PDO::FETCH_ASSOC);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ballbusters - Highscore</title>
<link href='https://fonts.googleapis.com/css?family=Abril+Fatface' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/style.css" charset="utf-8">
</head>
<body class="highScoreBody">
<div id="highScoreTable">
<table>
<thead><td class="align-left">Placement</td><td class="align-left">Player Name</td><td>Accuracy</td><td>Shots fired</td><td>Shotgun</td><td>Pistol</td><td>Date</td></thead>
<?php
$highscores = get_all_from_highscores();
usort($highscores, function($a, $b) {
return $b['accuracy'] - $a['accuracy'];
});
$rowCounter = 1;
foreach($highscores as $highscore)
{
echo "<tr>";
echo "<td>$rowCounter</td>";
echo "<td class='align-left'>{$highscore['player']}</td>";
echo "<td>{$highscore['accuracy']} %</td>";
echo "<td>{$highscore['totalShots']}</td>";
echo "<td>{$highscore['shotgunShots']}</td>";
echo "<td>{$highscore['pistolShots']}</td>";
echo "<td>{$highscore['highscoreDate']}</td>";
echo "</tr>";
$rowCounter++;
}
?>
</table>
</div>
</body>
</html>