-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
122 lines (101 loc) · 4.27 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
// Autor Boukernine Abdellatif
require_once("includes/database.php");
require_once("includes/pagination.php");
?>
<?php
// Pagination ************
//1. the current page number ($current_page)
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;
//2. records per page ($per_page)
$per_page = 1;
//3. total record count ($total_count)
$total_count = count_all_produit();
$pagination = new Pagination($page,$per_page,$total_count);
$sql = "SELECT * FROM produit";
$sql .= " LIMIT {$per_page}";
$sql .= " OFFSET {$pagination->offset()}";
?>
<?php
$result = find_by_sql($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="stylesheet" href="css/bootstrap.min.css">
<title>Pagination</title>
</head>
<body>
<style media="screen">
</style>
<header>
<nav class="navbar navbar-inverse bg-primary navbar-toggleable-sm">
<a href="#" class="navbar-brand">AbdellatifStore</a>
<div class="navbar-nav">
<a class="nav-item nav-link" href="#">Store</a>
<a class="nav-item nav-link" href="#">Services</a>
<a class="nav-item nav-link" href="#">Vente</a>
</div><!-- navbar-nav -->
</nav>
</header>
<div class="container"><br>
<div class="row">
<?php while ($donnes = $result->fetch()) { ?>
<div class="col-lg-3">
<div class="card">
<img class="card-img-top" src="images/<?php echo $donnes['image']; ?>" alt="" style="height:150px">
<div class="card-body">
<h5 class="text-success">2000DA</h5>
<p class="card-text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet numquam aspernatur.</p>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<!-- Pagination --><br><br>
<nav aria-label="...">
<ul class="pagination justify-content-center">
<?php if($pagination->has_previous_page()){?>
<li class="page-item">
<a class="page-link" href="<?php echo 'index.php?page='.$pagination->previous_page(); ?>" tabindex="-1">Previous</a>
</li>
<?php }else{ ?>
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">Previous</a>
</li>
<?php } ?>
<?php for($i=1; $i <= $pagination->total_pages(); $i++){ ?>
<?php if($i == $page){?>
<li class="page-item active">
<a class="page-link" href="#"><?php echo $i; ?><span class="sr-only">(current)</span></a>
</li>
<?php }else{ ?>
<li class="page-item"><a class="page-link" href="<?php echo 'index.php?page='.$i; ?>"><?php echo $i; ?></a></li>
<?php } ?>
<?php }?>
<?php if($pagination->has_next_page()){ ?>
<li class="page-item">
<a class="page-link" href="<?php echo 'index.php?page='.$pagination->next_page(); ?>">Next</a>
</li>
<?php }else{ ?>
<li class="page-item disabled">
<a class="page-link" href="#">Next</a>
</li>
<?php } ?>
</ul>
</nav>
<footer><br><br><br><br>
<div class="container">
<div class="col-12 col-md">
<small class="d-block mb-3 text-muted">Copyright (c) 2020 Copyright Holder All Rights Reserved, <a href="https://boukernineabdellatif.netlify.com">Boukernine abdellatif</a> </small>
</div>
</div>
</footer>
<script src="js/bootstrap.min.js"></script>
</body>
</html>