Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "rainbow";
  6.  
  7. $link = mysqli_connect($servername, $username, $password, $dbname);
  8.  
  9. if($link === false){
  10. die("ERROR: COuld not connect." . mysqli_connect_error());
  11. }
  12.  
  13. $sql = "SELECT name, nick, surname, team, country, birthdate, mouse, dpi, keyboard, headset FROM players";
  14. if($result = mysqli_query($link, $sql)){
  15. if(mysqli_num_rows($result) > 0){
  16. echo "<table>";
  17. echo "<tr>";
  18. echo "<th>name</th>";
  19. echo "<th>nick</th>";
  20. echo "<th>surname</th>";
  21. echo "<th>team</th>";
  22. echo "<th>country</th>";
  23. echo "<th>birthdate</th>";
  24. echo "<th>mouse</th>";
  25. echo "<th>dpi</th>";
  26. echo "<th>keyboard</th>";
  27. echo "<th>headset</th>";
  28. echo "</tr>";
  29. while ($row = mysqli_fetch_array($result)){
  30. echo "<tr>";
  31. echo "<td>" . $row['name'] . "</td>";
  32. echo "<td>" . $row['nick'] . "</td>";
  33. echo "<td>" . $row['surname'] . "</td>";
  34. echo "<td>" . $row['team'] . "</td>";
  35. echo "<td>" . $row['country'] . "</td>";
  36. echo "<td>" . $row['birthdate'] . "</td>";
  37. echo "<td>" . $row['mouse'] . "</td>";
  38. echo "<td>" . $row['dpi'] . "</td>";
  39. echo "<td>" . $row['keyboard'] . "</td>";
  40. echo "<td>" . $row['headset'] . "</td>";
  41. echo "</tr>";
  42. }
  43. echo "</table";
  44. mysqli_free_result($result);
  45. }
  46. else {
  47. echo "Ziadny vysledok a nic nefunguje";
  48. }
  49. }
  50.  
  51. mysqli_close($link);
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement