diff php/read/getLeaderboard.php @ 6:077b0a0a3e6d

remaining originals according to dependency walk
author Robert Boland <robert@markup.co.uk>
date Thu, 16 Feb 2017 22:29:02 +0000
parents
children 385ddd7c4b55 b7376319d25a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/php/read/getLeaderboard.php	Thu Feb 16 22:29:02 2017 +0000
@@ -0,0 +1,48 @@
+<?PHP
+
+include "../../../private/db.php";
+
+$query = "CALL b_getLeaderboard()";
+$results = mysqli_query($link, $query) or exit( mysqli_error( $link ));
+
+$output = "";
+$output .=  "<?xml version=\"1.0\"?>";
+$output .=  "<Leaderboard>";
+
+$leaderCount = 0;
+
+while($line = mysqli_fetch_assoc($results)) {
+	if($leaderCount < 10)
+	{
+		
+		
+		$id = trim($line["UserID"]);
+		
+		if($id != 42)
+		{
+			$name = trim($line["DisplayName"]);
+			$score = trim($line["Score"]);
+			
+			if($name == "")
+			{
+				$name = "User" . $id;
+			}
+			
+			$output .=  "<User>";
+			$output .=  "<UserID>" . htmlspecialchars($id) . "</UserID>";
+			$output .=  "<DisplayName>" . htmlspecialchars($name) . "</DisplayName>";
+			$output .=  "<Score>" . htmlspecialchars($score) . "</Score>";
+			$output .=  "</User>";
+			$leaderCount++;
+		}
+	}
+}
+
+$output .=  "</Leaderboard>";
+
+echo $output;
+
+mysqli_close($link);
+
+
+?>
\ No newline at end of file