Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Oppgave 4</title>
- <link rel = "stylesheet" href = "style.css" type = "text/css" media = "all"/>
- </head>
- <body>
- <?php
- // Connect to the employees database
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "employees";
- // Create connection
- $connect = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($connect->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // SQL query
- $sql = "SELECT first_name, last_name FROM `employees` ORDER BY last_name ASC";
- $result = $connect->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo $row["first_name"] . " " . $row["last_name"]."<br>";
- }
- }
- else {
- echo "0 results";
- }
- $connect->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement