-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpdracht3-2.php
42 lines (40 loc) · 1.17 KB
/
Opdracht3-2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Guest Book Posts</title>
</head>
<body>
<?php
$DBConnect = mysqli_connect("127.0.0.1", "root", "");
if ($DBConnect === FALSE) {
echo "<p>Unable to connect to the database server.</p>"
. "<p>Error code " . mysqli_errno() . ": " . mysqli_error()
. "</p>";
} else {
$DBName = "guestbook";
if (!mysqli_select_db($DBConnect, $DBName)) {
echo "<p>There are no entries in the guest book!</p>";
} else {
$TableName = "visitors";
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = mysqli_query($DBConnect, $SQLstring);
if (mysqli_num_rows($QueryResult) == 0) {
echo "<p>There are no entries in the guest book!</p>";
} else {
echo "<p>The following visitors have signed our guest book:</p>";
echo "<table width='100%' border='1'>";
echo "<tr><th>First Name</th> <th>Last Name </th></tr>";
while ($Row = mysqli_fetch_assoc($QueryResult)) {
echo "<tr><td>{$Row['first_name']}</td>";
echo "<td>{$Row['last_name']}</td></tr>";
}
}
mysqli_free_result($QueryResult);
}
mysqli_close($DBConnect);
}
?>
</form>
</body>
</html>