Advertisement
Guest User

Untitled

a guest
Feb 28th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2.     //Again, fill in your server data here!
  3.         $host="localhost"; // Host name
  4.         $username="----"; // Mysql username
  5.         $password="----"; // Mysql password
  6.         $db_name="----"; // Database name
  7.         $tbl_name="---"; // Table name
  8.  
  9.         // Connect to server and select database.
  10.         mysql_connect("$host", "$username", "$password")or die("cannot connect");
  11.         mysql_select_db("$db_name")or die("cannot select DB");
  12.  
  13.      //This query grabs the top 10 scores, sorting by score and timestamp.
  14.     $query = "SELECT * FROM Score ORDER by score DESC, ts ASC LIMIT 10";
  15.     $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  16.  
  17.     //We find our number of rows
  18.     $result_length = mysql_num_rows($result);
  19.    
  20.     //And now iterate through our results
  21.     for($i = 0; $i < $result_length; $i++)
  22.     {
  23.          $row = mysql_fetch_array($result);
  24.          echo $row['name'] . "\t" . $row['score'] . "\n"; // And output them
  25.     }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement