Advertisement
Guest User

Untitled

a guest
Jan 6th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. //gabber.php for getting the statistics
  2.  
  3. //first we want to define the server
  4.  
  5. $server = $_GET['server_id'];
  6.  
  7. if (£server_id == 1){
  8.  
  9. $server = "Zues";
  10. } else if (£server_id == 2){
  11. $server = "Ares";
  12. } else {
  13. //the server must be Enyo
  14. $server = "Enyo";
  15. }
  16.  
  17. //okay so we know which server we are getting lets pull the info from the Database
  18.  
  19. $user = "mymysqluser";
  20. $pass = "mymysqlpass";
  21.  
  22.  
  23. // try catch the error if fails
  24. try {
  25.     $dbh = new PDO('mysql:host=localhost;dbname=mydatabase', $user, $pass);
  26.     foreach($dbh->query('SELECT * from FOO') as $row) {
  27.         print_r($row);
  28.     }
  29.     $dbh = null;
  30. } catch (PDOException $e) {
  31.     print "Error!: " . $e->getMessage() . "<br/>";
  32.     die();
  33. }
  34.  
  35.  
  36. $sth = $dbh->prepare("SELECT * FROM player_stats WHERE server_name=".$server."LIMIT 1000 ORDER BY kills DESC");
  37. $sth->execute();
  38.  
  39. //place the results into an array
  40.  
  41. $results = $sth->fetchAll();
  42.  
  43. header('Content-Type: application/json');
  44.  
  45. $results = json_econde($results);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement