Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "sak";
- $password = "saksak123";
- $dbname = "sak";
- $tablename = "players";
- //Create connection
- $db = new mysqli($servername, $username, $password, $dbname);
- //Check connection
- if($db->connect_error)
- {
- die("Connection failed: " . $db->connect_error);
- }
- else
- echo "Connection Successful! \n";
- //Query the database
- $sql = "SELECT * FROM " . $tablename .
- " ORDER BY ilvl DESC";
- $result = $db->Query($sql);
- //Show if there is a result
- if($result->num_rows > 0)
- {
- //output data of each row
- $numRow = 0;
- while($row = $result->fetch_assoc())
- {
- if($numRow == 5)
- break;
- $numRow++;
- echo $numRow . ": " . $row["Name"];
- echo ": " . $row ["ilvl"];
- echo "\n";
- }
- }
- else
- echo "No results found";
- $db->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement