Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <?php
  2. $link = mysqli_connect("localhost", "root", "", "samp");
  3.  
  4. if($link === false){
  5. die("ERROR: Could not connect. " . mysqli_connect_error());
  6. }
  7.  
  8. $sql = "SELECT * FROM test";
  9. if($result = mysqli_query($link, $sql)){
  10. if(mysqli_num_rows($result) > 0){
  11. echo "<table>";
  12. echo "<tr>";
  13. echo "<th>ID</th>";
  14. echo "<th>Username</th>";
  15. echo "</tr>";
  16. while($row = mysqli_fetch_array($result)){
  17. echo "<tr>";
  18. echo "<td>" . $row['id'] . "</td>";
  19. echo "<td>" . $row['username'] . "</td>";
  20. echo "</tr>";
  21. }
  22. echo "</table>";
  23. mysqli_free_result($result);
  24. } else{
  25. echo "No records matching your query were found.";
  26. }
  27. } else{
  28. echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
  29. }
  30.  
  31. mysqli_close($link);
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement