Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //gabber.php for getting the statistics
- //first we want to define the server
- $server = $_GET['server_id'];
- if (£server_id == 1){
- $server = "Zues";
- } else if (£server_id == 2){
- $server = "Ares";
- } else {
- //the server must be Enyo
- $server = "Enyo";
- }
- //okay so we know which server we are getting lets pull the info from the Database
- $user = "mymysqluser";
- $pass = "mymysqlpass";
- // try catch the error if fails
- try {
- $dbh = new PDO('mysql:host=localhost;dbname=mydatabase', $user, $pass);
- foreach($dbh->query('SELECT * from FOO') as $row) {
- print_r($row);
- }
- $dbh = null;
- } catch (PDOException $e) {
- print "Error!: " . $e->getMessage() . "<br/>";
- die();
- }
- $sth = $dbh->prepare("SELECT * FROM player_stats WHERE server_name=".$server."LIMIT 1000 ORDER BY kills DESC");
- $sth->execute();
- //place the results into an array
- $results = $sth->fetchAll();
- header('Content-Type: application/json');
- $results = json_econde($results);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement