Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2. if (empty($_COOKIE['user'])) {
  3.     echo '<script>window.location.href = "../../"</script>';
  4. }
  5.  
  6. include '../../mysqlHandler.php';
  7.  
  8. openConnection();
  9.  
  10. $user_id = 0;
  11.  
  12. if (!empty($_COOKIE['user'])) {
  13.     $result = executeQuery('select user_id from user where username ="' . $_COOKIE['user'] . '"');
  14. }
  15.  
  16. // getting the user's id based on their cookie>username
  17. if ($result) {
  18.     while ($row = mysql_fetch_array($result)) {
  19.         $user_id = $row['user_id'];
  20.     }
  21. }
  22. ?>
  23.  
  24. <?php
  25. include '../../t/headSectionUnclosed.php';
  26. echo '</head> <body>';
  27. include '../../t/userBar.php';
  28. ?>
  29.  
  30. <h1>
  31.     High Scores List
  32. </h1>
  33. <hr>
  34. <h2>
  35.     Your Best Five Scores
  36. </h2>
  37. <?php
  38. $scores = executeQuery('select score from user_score where user_id = ' . $user_id . ' order by score desc limit 0, 5');
  39. $count = 0;
  40. if (mysql_num_rows($scores) > 0) {
  41.     echo '<table id="highscores-table">';
  42.     echo '<tr>';
  43.     echo '<th>&nbsp;</th>';
  44.     echo '<th>Score</th>';
  45.     echo '</tr>';
  46.     if ($scores) {
  47.         while ($row = mysql_fetch_array($scores)) {
  48.             echo '<tr>';
  49.             echo '<td>';
  50.             echo++$count;
  51.             echo '</td><td>';
  52.             echo $row['score'];
  53.             echo '</td>';
  54.             echo '</tr>';
  55.         }
  56.     }
  57.     echo '</table>';
  58. } else {
  59.     echo "<em>You don't have any high scores yet.</em>";
  60. }
  61.  
  62. echo '<br><br>';
  63. echo '<a href="../" id="button-link">Improve your scores &rarr;</a>';
  64. echo '<br><br>';
  65. ?>
  66.  
  67. <hr>
  68.  
  69. <h2>
  70.     Global Top 10
  71. </h2>
  72.  
  73. <table id="highscores-table">
  74.     <tr>
  75.         <th>Rank</th>
  76.         <th>User</th>
  77.         <th>Score</th>
  78.     </tr>
  79.     <?php
  80.     $global_high_scores = executeQuery('select u.username, s.score from user u, user_score s where u.user_id = s.user_id order by s.score desc limit 0, 10');
  81.     if ($global_high_scores) {
  82.         $ranking = 0;
  83.         while ($row = mysql_fetch_array($global_high_scores)) {
  84.             $ranking++;
  85.  
  86.             echo '<tr>';
  87.             echo '<td>';
  88.             echo $ranking;
  89.             echo '</td>';
  90.             echo '<td>';
  91.             echo $row['username'];
  92.             echo '</td>';
  93.             echo '<td>';
  94.             echo $row['score'];
  95.             echo '</td>';
  96.             echo '</tr>';
  97.         }
  98.     }
  99.     ?>
  100. </table>
  101.  
  102. <br><br>
  103. <a href="../" id="button-link">Improve your scores &rarr;</a>
  104. <br><br>
  105.  
  106. <br><br><br><br>
  107. </body></html>