-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcredits.php
67 lines (50 loc) · 1.89 KB
/
credits.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
55
56
57
58
59
60
61
62
63
64
65
66
<?php require_once('src/php/config.php');
try {
$db = new PDO('sqlite:myfavoritedogs.db');
$stmt = $db->prepare('SELECT * FROM dogbreeds INNER JOIN photos ON dogbreeds.id = photos.breed_id ORDER BY title');
$stmt->execute();
$allData = $stmt->fetchAll();
} catch (PDOException $e) {
echo $e->getMessage();
}
$pageTitle = "Photo credits";
include 'header.php';
?>
<div class="hero">
<div class="titleCard" style="background-image: url('<?= $homeURL . "/src/images/large/" . $allData[rand(0, count($allData) - 1)]['photo_url'] ?>.jpg')">
<div class="gradient"></div>
<h1 class="title">Photo credits</h1>
</div>
</div>
<?php include 'notice.php' ?>
<main>
<table class="styled-table">
<thead>
<tr>
<th>Photo</th>
<th>Breed</th>
<th>Author</th>
<th>Name of the dog</th>
</tr>
</thead>
<tbody>
<?php
foreach ($allData as $photo) { ?>
<tr>
<td><div class="imgContainer"><img src="<?= $homeURL . '/src/images/small/' . $photo['photo_url'] ?>.jpg" loading="lazy"></div></td>
<td><?= $photo['title'] ?></td>
<td><?php
if ($photo['author_url']) {
echo '<a href="' . $photo['author_url'] . '">' . $photo['photo_author'] . '</a>';
} else {
echo $photo['photo_author'];
}
?>
<td><?= $photo['dog_name'] ?></td>
</tr>
<?php }
?>
</tbody>
</table>
</main>
<?php include 'footer.php' ?>