summaryrefslogtreecommitdiffstats
path: root/includes/datas.php
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2011-11-05 03:04:49 -0700
committerraylu <raylu@mixpanel.com>2011-11-05 03:04:49 -0700
commitcf4af138b16da878404cf3319d5d988dacee198a (patch)
tree41187e9c8206657f9f5138de70c5e5a6f447a251 /includes/datas.php
parent264ed976da6b3012209386a76520327faeddf82e (diff)
downloadpathery-cf4af138b16da878404cf3319d5d988dacee198a.tar.xz
new layout
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;
+}
+
+?>