summaryrefslogtreecommitdiffstats
path: root/includes/datas.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/datas.php')
-rw-r--r--includes/datas.php53
1 files changed, 52 insertions, 1 deletions
diff --git a/includes/datas.php b/includes/datas.php
index 0d3d0c5..912eea8 100644
--- a/includes/datas.php
+++ b/includes/datas.php
@@ -1 +1,52 @@
-<?PHP // For interaction with the SQL database. // include_once('db.inc.php'); //Select Stats/Scores. function topScores($mapid, $top = 5) { $sql = " SELECT timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff, users.displayName as display, solutions.moves as m, users.ID as ID FROM `users` JOIN `solutions` ON users.ID = solutions.userID WHERE solutions.mapID = '$mapid' ORDER BY solutions.moves DESC, solutions.dateModified ASC LIMIT $top "; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { $output .= "<table style='border:1px solid #FFF'>"; $output .= "<tr>"; $output .= "<th style='border:1px solid #ccc'>Rank</th>"; $output .= "<th style='border:1px solid #ccc'>Name</th>"; $output .= "<th style='border:1px solid #ccc'>Moves</th>"; $output .= "<th style='border:1px solid #ccc'>Time taken</th>"; $output .= "</tr>"; while (list($diff, $display, $moves, $userID) = mysql_fetch_row($result)) { $i++; if ($_SESSION['userID'] == $userID) $output .= "<tr style='background-color: #338899;'>"; else $output .= "<tr>"; $output .= "<td>$i</td>"; $output .= "<td><span title='UserID: $userID'>$display</span></td>"; $output .= "<td>$moves</td>"; $output .= "<td>$diff</td>"; //$output .= "<b>$i. <span title='UserID: $userID'>$display</span> with $moves moves. In $diff<br /></b>"; $output .= "</tr>"; } $output .= "</table>"; } return $output; } ?> \ No newline at end of file
+<?PHP
+// For interaction with the SQL database.
+//
+
+include_once('db.inc.php');
+
+//Select Stats/Scores.
+function topScores($mapid, $top = 5) {
+ $sql = "
+ SELECT
+ timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff,
+ users.displayName as display,
+ solutions.moves as m,
+ users.ID as ID
+ FROM
+ `users`
+ JOIN `solutions`
+ ON users.ID = solutions.userID
+ WHERE solutions.mapID = '$mapid'
+ ORDER BY solutions.moves DESC, solutions.dateModified ASC
+ LIMIT $top
+ ";
+ $result = mysql_query($sql);
+
+ if (mysql_num_rows($result) > 0) {
+ $output .= "<table class='score'>";
+ $output .= "<tr>";
+ $output .= "<th>Rank</th>";
+ $output .= "<th>Name</th>";
+ $output .= "<th>Moves</th>";
+ $output .= "<th>Time taken</th>";
+ $output .= "</tr>";
+ while (list($diff, $display, $moves, $userID) = mysql_fetch_row($result)) {
+ $i++;
+ if ($_SESSION['userID'] == $userID)
+ $output .= "<tr style='background-color: #356;'>";
+ else
+ $output .= "<tr>";
+
+ $output .= "<td>$i</td>";
+ $output .= "<td><span title='UserID: $userID'>$display</span></td>";
+ $output .= "<td>$moves</td>";
+ $output .= "<td>$diff</td>";
+ //$output .= "<b>$i. <span title='UserID: $userID'>$display</span> with $moves moves. In $diff<br /></b>";
+ $output .= "</tr>";
+ }
+ $output .= "</table>";
+ }
+ return $output;
+}
+
+?>