Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Employees List</title>
  5. </head>
  6. <body>
  7. <h1>Employees List</h1>
  8. <?php
  9. // variables initialization
  10. $host="localhost";
  11. $user="user";
  12. $password="S3cP@ss";
  13. $db="city_stats";
  14. // establish a connection
  15. if ($dbh=mysqli_connect($host, $user, $password, $db)) {
  16. // initialize the query statement
  17. $query="SELECT city_name, population FROM cities";
  18. if ($result=mysqli_query($dbh, $query)) {
  19. // we have data, so let's list it
  20.  
  21. echo "<ol>";
  22.  
  23. while ($row=mysqli_fetch_array($result, MYSQL_ASSOC)) {
  24. echo "<li>".$row['city_name'].", ".$row['population']."</li>";
  25. }
  26. echo "</ol>";
  27. }
  28. else
  29. echo "<h2>ERROR: No data!</h2>";
  30. }
  31. else
  32. echo "<h2>ERROR: No connection!</h2>";
  33. ?>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement