-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·46 lines (36 loc) · 1.48 KB
/
Copy pathindex.php
File metadata and controls
executable file
·46 lines (36 loc) · 1.48 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
// +++++++++++++++++++++++++++++++++++++++++++++++++++
// This example shows how to use Class CtrlPagination
// +++++++++++++++++++++++++++++++++++++++++++++++++++
$resultsQty = 35; // Just an example.
// The value for $resultsQty can be returned from a DB query
// like "SELECT count(*) FROM table_name WHERE conditions;"
$limit = 10; // setup how many records per page
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$url = "https://";
else
$url = "http://";
$url.= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$baseLink = strtok($url, '?');
include_once("ctrlPagination.php");
include_once("intPagination.php");
include_once("cPagination.php");
$ctrlPagination = new CtrlPagination();
$intPagination = new IntPagination();
$cPagination = new CPagination();
$ctrlPagination->calculate($cPagination, $resultsQty, $limit);
$offset = $cPagination->getOffset();
// Now, use $limit and $offset to extract complete records from DB
// similar to: "SELECT columns FROM table_name
// WHERE conditions LIMIT :limit OFFSET :offset"
?><!DOCTYPE html>
<head>
<title>Pagination example</title>
<link rel="stylesheet" href="./template.css?v=<?php echo time(); ?>" type="text/css">
</head>
<body><div class="column-100">
<?php $ctrlPagination->draw($cPagination, $intPagination, $baseLink); ?>
<?php $ctrlPagination->stats($cPagination, $intPagination); ?>
</div>
</body>
</html>