Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <?php
  2. //Note:
  3. //This version of the code is UNtested
  4.  
  5. //Configuration
  6. $host = "localhost";
  7. $user = "root";
  8. $pass = "";
  9. $characters = "characters"; //Karakter adatbázis neve.
  10. $con = mysql_connect($host,$user,$pass) or die (mysql_error());
  11. $border = 0;
  12. $hanyember = 10;
  13.  
  14. //Function
  15. function getTime($total)
  16. {
  17.   $day = (int)($total/86400);
  18.   $total = $total - ($day*86400);
  19.   $hour = (int)($total/3600);
  20.   $total = $total - ($hour*3600);
  21.   $minute = (int)($total/60);
  22.  
  23.   $time = $day." nap ".$hour." óra ".$minute." perc";
  24.   return $time;
  25. }
  26.  
  27. //Query
  28. $query = mysql_query("SELECT `name`, `class`, `race`, `totaltime` FROM `".$characters."`.`characters` ORDER BY `totaltime`") or die (mysql_error());
  29. $numrows = mysql_num_rows($query);
  30. $i = 0;
  31.  
  32. //Printing the upper part of the table
  33. echo "<table border='" . $border . "'>";
  34. echo "<tr>";
  35. echo "<td>";
  36. echo "Név";
  37. echo "</td>";
  38. echo "<td>";
  39. echo "Class";
  40. echo "</td>";
  41. echo "<td>";
  42. echo "Race";
  43. echo "</td>";
  44. echo "<td>";
  45. echo "Játékidő";
  46. echo "</td>";
  47. echo "</tr>";
  48. //End
  49.  
  50. while($i < $numrows)
  51. {
  52. if($i+1 == $hanyember)
  53. break;
  54. $nev = mysql_result($query, $i, 0);
  55. $class = mysql_result($query, $i, 1);
  56. $race = mysql_result($query, $i, 2);
  57. $ido = getTime(mysql_result($query, $i, 3));
  58.  
  59. //TODO: change the race and class numbers to text, anybody can do it...
  60.  
  61. echo "<tr>";
  62. echo "<td>";
  63. echo $nev;
  64. echo "</td>";
  65. echo "<td>";
  66. echo $class;
  67. echo "</td>";
  68. echo "<td>";
  69. echo $race;
  70. echo "</td>";
  71. echo "<td>";
  72. echo $ido;
  73. echo "</td>";
  74. echo "</tr>";
  75.  
  76. $i += 1;
  77. }
  78.  
  79. echo "</table>";
  80. echo "<br>Made by Doomkiller, Improved by $0undX";
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement