-
Notifications
You must be signed in to change notification settings - Fork 0
/
animals-sheep.php
41 lines (30 loc) · 1.54 KB
/
animals-sheep.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
<?php
$num_of_animals_per_page = 8;
$current_page = isset($_GET['p']) && is_numeric($_GET['p']) ? (int)$_GET['p'] : 1;
$query="SELECT * FROM animals a LEFT JOIN photos p ON a.idanimals = p.fk_idanimals
INNER JOIN breeds b ON a.fk_idbreeds = b.idbreeds INNER JOIN animal_types aty ON b.fk_idanimal_types = aty.idanimal_types
INNER JOIN sex s ON a.fk_idsex = s.idsex LEFT JOIN pregnancies prg ON a.fk_idpregnancies = prg.idpregnancies
INNER JOIN health h ON a.fk_idhealth = h.idhealth
WHERE lower(aty.type) = lower('Ovca')
ORDER BY idanimals DESC LIMIT ?, ?";
$stmt = $pdo->prepare($query);
$stmt->execute();
$stmt->bindValue(1, ($current_page - 1) * $num_of_animals_per_page, PDO::PARAM_INT);
$stmt->bindValue(2, $num_of_animals_per_page, PDO::PARAM_INT);
$stmt->execute();
$animals = $stmt->fetchAll(PDO::FETCH_ASSOC);
$total_animals = $pdo->query('SELECT * FROM animals')->rowCount();
?>
<?=template_header("Ovce")?>
<?=show_animals($animals)?>
<!-- page navigation buttons -->
<div class="row justify-content-center">
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-2" id="page-btn" role="group" aria-label="First group">
<?php for($i = 0; $i <= ($total_animals/$num_of_animals_per_page); $i++): ?>
<a href="./index.php?page=animals&p=<?=$i + 1?>"><button type="button" class="btn btn-secondary"><?=$i + 1?></button></a>
<?php endfor; ?>
</div>
</div>
</div>
<?=template_footer()?>