-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
54 lines (51 loc) · 1.6 KB
/
index.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
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require_once dirname(__FILE__) . '/library/base.php';
$books = $bookshelf->findAll();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Bookshelf</title>
<style type="text/css">
table {
border: 1px solid black;
border-collapse: collapse;
width: 600px;
}
th {
background-color: #E9E9E9;
}
td {
padding: 5px;
}
</style>
</head>
<body>
<h1>Bookshelf</h1>
<p>
<a href="book-form.php">Add Book</a>
</p>
<?php if (count($books) > 0): ?>
<table>
<tr>
<th>Title</th><th>Author</th>
</tr>
<?php foreach ($books as $book): ?>
<tr>
<td>
<a href="book-form.php?id=<?php echo $book['id']; ?>">
<?php echo htmlspecialchars($book['title'], ENT_COMPAT, 'UTF-8'); ?>
</a>
</td>
<td>
<?php echo htmlspecialchars($book['author'], ENT_COMPAT, 'UTF-8'); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
<p>We have no books!</p>
<?php endif; ?>
</body>
</html>