summaryrefslogtreecommitdiffstats
path: root/templates/highscores.tpl.php
diff options
context:
space:
mode:
Diffstat (limited to 'templates/highscores.tpl.php')
-rw-r--r--templates/highscores.tpl.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/templates/highscores.tpl.php b/templates/highscores.tpl.php
new file mode 100644
index 0000000..9bc889f
--- /dev/null
+++ b/templates/highscores.tpl.php
@@ -0,0 +1,35 @@
+<h1>Highscores</h1>
+
+<?php
+
+ require_once(SITE_ROOT . "/models/" . "database.php");
+ $database = new Database();
+ $highscores = $database->getHighscores();
+
+ /*
+ * Sort multidimensional array according to $array[][1]
+ */
+
+ $sortArray = array();
+ foreach ($highscores as $key => $value) {
+ $sortArray[$key] = $value[1];
+ }
+ array_multisort($sortArray, SORT_DESC, SORT_NUMERIC, $highscores);
+
+ $place = 0;
+
+ foreach ($highscores as $highscore) {
+ if ($highscore[1] <= 21) {
+ $place++;
+ }
+ if ($place != 0) {
+ echo "Place $place: ";
+ }
+ $score = round($highscore[1], 2);
+ echo" <b>$highscore[0]</b> with <b>$score</b> Points in <b>$highscore[2]</b> games<br />\n";
+ }
+
+?>
+
+<br /><br />
+<a href="?menu">Back to menu</a>