Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Oppgave 4</title>
  5. <link rel = "stylesheet" href = "style.css" type = "text/css" media = "all"/>
  6.  
  7. </head>
  8. <body>
  9.  
  10. <?php
  11.  
  12. // Connect to the employees database
  13. $servername = "localhost";
  14. $username = "root";
  15. $password = "";
  16. $dbname = "employees";
  17.  
  18. // Create connection
  19. $connect = new mysqli($servername, $username, $password, $dbname);
  20.  
  21. // Check connection
  22. if ($connect->connect_error) {
  23. die("Connection failed: " . $conn->connect_error);
  24. }
  25.  
  26. // SQL query
  27. $sql = "SELECT first_name, last_name FROM `employees` ORDER BY last_name ASC";
  28. $result = $connect->query($sql);
  29.  
  30. if ($result->num_rows > 0) {
  31. // output data of each row
  32. while($row = $result->fetch_assoc()) {
  33. echo $row["first_name"] . " " . $row["last_name"]."<br>";
  34. }
  35. }
  36. else {
  37. echo "0 results";
  38. }
  39.  
  40. $connect->close();
  41. ?>
  42.  
  43. </body>
  44. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement