Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>mysql example</title>
- <!-- stylsheets -->
- GNU nano 2.2.6 File: week1exercises.php
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>mysql example</title>
- <!-- stylsheets -->
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <?php
- $servername = "localhost";
- $username = "student";
- $password = "";
- $dbname = "employees";
- // Create connection
- $conn = new mysqli ( $servername, $username, $password, $dbname );
- // Check connection
- if ($conn->connect_error) {
- die ( "Connection failed: " . $conn->connect_error );
- }
- $sql = "SELECT s.salary, e.first_name, e.last_name
- FROM salaries s
- INNER JOIN employees e ON s.emp_no=e.emp_no
- ORDER BY s.salary DESC
- LIMIT 10";
- $result = $conn->query ( $sql );
- echo "<table border='1' cellpadding='2' cellspacing='2'";
- echo "<tr><td>Firtsname</td><td>Surname</td><td>Salary</td></tr>";
- if ($result->num_rows > 0) {
- // output data of each row
- while ( $row = $result->fetch_assoc () ) {
- echo "<tr><td> " . $row ["first_name"] . "</td><td> " . $row ["last_name"] . "</td><td> " . $row ["salary"] . "</td></tr>";
- }
- } else {
- echo "10 results";
- }
- $conn->close ();
- ?>
- <div id="form">
- <form action="surname.php" >
- <input type="text"name="lastname" placeholder="Surname"><br>
- <input type="submit" value="Search">
- </form>
- </div><br>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement