-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
46 lines (41 loc) · 1.03 KB
/
Copy pathindex.php
File metadata and controls
46 lines (41 loc) · 1.03 KB
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
<?php
$pdo = require 'db.php';
$contacts = [];
if ($pdo) {
$stmt = $pdo->query("SELECT * FROM contacts");
$contacts = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Home</title>
</head>
<body>
<header>
<nav>
<a href="/about.php">About</a>
</nav>
</header>
<main>
<h1>Home</h1>
<a href="create.php">Create new contact</a>
<ul>
<?php
foreach ($contacts as $contact) {
echo "
<li>
<img src='{$contact['image']}' alt='Contact Image' width='256' height='144' />
<a href='delete.php?id={$contact['id']}'>Delete</a>
<p>Name: {$contact['name']}</p>
</li>
";
}
?>
</ul>
</main>
<?php require 'footer.php'; ?>
</body>
</html>