Created
June 24, 2018 20:05
-
-
Save fernandozamoraj/18408e99da972103107ec0d74416765d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Books</title> | |
</head> | |
<body> | |
<?php | |
$servername = "localhost"; | |
$username = "bpdemo"; | |
$password = "bpdemo"; | |
$dbname = "bpdemo"; | |
$conn = new mysqli($servername, $username, $password, $dbname); | |
// Check connection | |
if ($conn->connect_error) { | |
die("Connection failed: " . $conn->connect_error); | |
echo "Connection Failed...."; | |
} | |
$sql = "SELECT book_id, title, author, pages FROM books"; | |
$result = $conn->query($sql); | |
echo "\n <table>" . | |
"\n <tr> " . | |
"\n <th>Book Id</th>" . | |
"\n <th>Title</th>" . | |
"\n <th>Author</th>" . | |
"\n <th>Pages</th>" . | |
"\n <tr>" . | |
"\n "; | |
if ($result->num_rows > 0) { | |
while($row = $result->fetch_assoc()) { | |
echo "\n <tr>" . | |
"\n <td> " . $row['book_id'] . "</td>" . | |
"\n <td> " . $row['title'] . "</td>" . | |
"\n <td> " . $row['author'] . "</td>" . | |
"\n <td> " . $row['pages'] . "</td>" . | |
"\n </tr>"; | |
} | |
} | |
echo "\n </table>"; | |
$conn->close(); | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment