Advertisement
Lillenooben

Untitled

Apr 6th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "sak";
  4. $password = "saksak123";
  5. $dbname = "sak";
  6. $tablename = "players";
  7.  
  8. //Create connection
  9. $db = new mysqli($servername, $username, $password, $dbname);
  10.  
  11.  
  12. //Check connection
  13. if($db->connect_error)
  14. {
  15. die("Connection failed: " . $db->connect_error);
  16. }
  17. else
  18. echo "Connection Successful! \n";
  19.  
  20. //Query the database
  21. $sql = "SELECT * FROM " . $tablename .
  22. " ORDER BY ilvl DESC";
  23. $result = $db->Query($sql);
  24.  
  25.  
  26.  
  27.  
  28. //Show if there is a result
  29. if($result->num_rows > 0)
  30. {
  31. //output data of each row
  32. $numRow = 0;
  33. while($row = $result->fetch_assoc())
  34. {
  35. if($numRow == 5)
  36. break;
  37. $numRow++;
  38. echo $numRow . ": " . $row["Name"];
  39. echo ": " . $row ["ilvl"];
  40. echo "\n";
  41. }
  42.  
  43. }
  44. else
  45. echo "No results found";
  46.  
  47. $db->close();
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement