Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2. $name = $_GET["name"];
  3. $scorepos;
  4. $score = $_GET["score"];
  5. $valid = $_GET["valid"];
  6. $mysql_host = "mysql15.000webhost.com";
  7. $mysql_database = "a4542026_flash";
  8. $mysql_user = "";
  9. $mysql_password = "";
  10.  
  11.  // Connects to your Database
  12. mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error());
  13. mysql_select_db($mysql_database) or die(mysql_error());
  14.  
  15. // Insert regardless of score
  16. mysql_query("INSERT INTO scores SET name=$name, score=$score");
  17.  
  18. // Get all the scores in order
  19. $result = mysql_query("SELECT * FROM scores ORDER BY score DESC");
  20.  
  21. // Placeholder score value
  22. $score = 0;
  23.  
  24. if (mysql_num_rows($result) > 8)
  25. {
  26.     // Only interested in deleting data if more than 8 values
  27.    
  28.     // Seek to the eight row in the result
  29.     mysql_data_seek($reslt, 8);
  30.    
  31.     // Gets the eight row's data
  32.     $row = mysql_fetch_assoc($result);
  33.    
  34.     // Save the score from the eight player's highscore
  35.     $score = intval($row["score"]);
  36.    
  37.     // Free the result so we can work on another
  38.     mysql_free_result($result);
  39.    
  40.     // Delete all players with a lower score than the eight person
  41.     mysql_query("DELETE FROM scores WHERE score<$score");
  42.    
  43.    
  44. }
  45.  
  46. mysql_close();
  47.  
  48. echo 'thanks,'.$name.'!';
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement