Mercurial > hg > ywww
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5:55445b456ad0 | 6:077b0a0a3e6d |
|---|---|
| 1 <?PHP | |
| 2 | |
| 3 include "../../../private/db.php"; | |
| 4 | |
| 5 $query = "CALL b_getLeaderboard()"; | |
| 6 $results = mysqli_query($link, $query) or exit( mysqli_error( $link )); | |
| 7 | |
| 8 $output = ""; | |
| 9 $output .= "<?xml version=\"1.0\"?>"; | |
| 10 $output .= "<Leaderboard>"; | |
| 11 | |
| 12 $leaderCount = 0; | |
| 13 | |
| 14 while($line = mysqli_fetch_assoc($results)) { | |
| 15 if($leaderCount < 10) | |
| 16 { | |
| 17 | |
| 18 | |
| 19 $id = trim($line["UserID"]); | |
| 20 | |
| 21 if($id != 42) | |
| 22 { | |
| 23 $name = trim($line["DisplayName"]); | |
| 24 $score = trim($line["Score"]); | |
| 25 | |
| 26 if($name == "") | |
| 27 { | |
| 28 $name = "User" . $id; | |
| 29 } | |
| 30 | |
| 31 $output .= "<User>"; | |
| 32 $output .= "<UserID>" . htmlspecialchars($id) . "</UserID>"; | |
| 33 $output .= "<DisplayName>" . htmlspecialchars($name) . "</DisplayName>"; | |
| 34 $output .= "<Score>" . htmlspecialchars($score) . "</Score>"; | |
| 35 $output .= "</User>"; | |
| 36 $leaderCount++; | |
| 37 } | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 $output .= "</Leaderboard>"; | |
| 42 | |
| 43 echo $output; | |
| 44 | |
| 45 mysqli_close($link); | |
| 46 | |
| 47 | |
| 48 ?> |
