-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
60 lines (43 loc) · 1.47 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
55
56
57
58
59
60
<?php include_once 'config/setup.php' ?>
<?php include "inc/bootstrap.php";
$auth = App::getAuth();
?>
<?php include "inc/header.php"; ?>
<body>
<h1 id="h1_index"> Toutes les photos disponibles sur notre site </h1>
<?php
$db = App::getDatabase();
$return = $db->query("SELECT COUNT(id_photo) as nbrPhoto FROM camagru.photo")->fetch();
$nbrPhoto = $return->nbrPhoto;
$perPage = 5;
$nbrPage = ceil($nbrPhoto / $perPage);
if (isset($_GET['page']) && $_GET['page'] > 0 && $_GET['page'] <= $nbrPage){
$currentPage = $_GET['page'];
}
else
$currentPage = 1;
$ret = $db->query("SELECT * FROM camagru.photo ORDER BY creation_date DESC LIMIT ". (($currentPage - 1) * $perPage) .", $perPage");
while ($display_gallery = $ret->fetch()) {
?>
<div id="photo_index">
<?= $display_gallery->login;?><br/>
<hr/>
<img src="<?= $display_gallery->path_to_photo;?>" /> <br/><br/>
<div style="display: flex; justify-content: space-evenly;">
<p><?php echo $display_gallery->like_count?> likes</p>
<p><?php echo $display_gallery->dislike_count?> dislikes</p>
</div>
<a href="comments_likes.php?id_photo=<?=htmlentities($display_gallery->id_photo);?>">Plus de détails</a>
</div>
<?php
}
for ($i = 1; $i <= $nbrPage; $i++){
if ($i == $currentPage)
echo " $i /";
else
echo " <a href=\"index.php?page=$i\">$i</a> /";
}
?>
</body>
<div class="clear"></div>
<?php include "inc/footer.php"; ?>