Advertisement
Guest User

Untitled

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