Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2.    
  3.     $con=mysqli_connect("185.216.27.62","loonyland","","loonyland");
  4.    
  5.     // Check connection
  6.     if (mysqli_connect_errno())
  7.     {
  8.         echo "Failed to connect to MySQL: " . mysqli_connect_error();
  9.     }
  10.    
  11.     // This SQL statement selects ALL from the table 'Locations'
  12.     $sql = "SELECT * FROM player";
  13.    
  14.     // Check if there are results
  15.     if ($result = mysqli_query($con, $sql))
  16.     {
  17.         // If so, then create a results array and a temporary one
  18.         // to hold the data
  19.         $resultArray = array();
  20.         $tempArray = array();
  21.        
  22.         // Loop through each row in the result set
  23.         while($row = $result->fetch_object())
  24.         {
  25.             // Add each row into our results array
  26.             $tempArray = $row;
  27.             array_push($resultArray, $tempArray);
  28.         }
  29.        
  30.         // Finally, encode the array to JSON and output the results
  31.         echo json_encode($resultArray);
  32.     }
  33.    
  34.     // Close connections
  35.     mysqli_close($con);
  36.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement