FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-array-pagination/example.php at master · lotsofcode/php-array-pagination · GitHub
lotsofcode
/
php-array-pagination
Public
Notifications
You must be signed in to change notification settings
Fork
10
Star
23
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
php-array-pagination
/
example.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
107 lines (101 loc) · 3.62 KB
Breadcrumbs
php-array-pagination
/
example.php
Copy path
File metadata and controls
107 lines (101 loc) · 3.62 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<?php
/************************************************************\
*
* PHP Array Pagination Copyright 2007 - Derek Harvey
* www.lotsofcode.com
*
* This file is part of PHP Array Pagination .
*
* PHP Array Pagination is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PHP Array Pagination is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PHP Array Pagination ; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\************************************************************/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<title>PHP Array Pagination</title>
<style>
<!--
body {
font-family: Tahoma, Verdana, Arial, Sans-serif;
font-size: 11px;
}
hr {
border: 1px #ccc;
border-style: none none solid none;
margin: 20px 0;
}
a {
color: #333;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a.selected {
font-weight: bold;
text-decoration: underline;
}
.numbers {
line-height: 20px;
word-spacing: 4px;
}
//-->
</style>
</head>
<body>
<h1>PHP Array Pagination</h1>
<hr />
<?php
ini_set
(
'
display_errors
'
,
'
On
'
);
error_reporting
(
E_ALL
);
// Include the pagination class
include
'
pagination.class.php
'
;
// some example data
foreach
(
range
(
1
,
200
)
as
$
value
) {
$
products
[] =
array
(
'
Product
'
=>
'
Product
'
.
$
value
,
'
Price
'
=>
rand
(
100
,
1000
),
);
}
// If we have an array with items
if
(
count
(
$
products
)) {
// Create the pagination object
$
pagination
=
new
pagination
(
$
products
, (
isset
(
$
_GET
[
'
page
'
]) ?
$
_GET
[
'
page
'
] :
1
),
15
);
// Decide if the first and last links should show
$
pagination
->
setShowFirstAndLast
(
false
);
// You can overwrite the default seperator
$
pagination
->
setMainSeperator
(
'
|
'
);
// Parse through the pagination class
$
productPages
=
$
pagination
->
getResults
();
// If we have items
if
(
count
(
$
productPages
) !=
0
) {
// Create the page numbers
echo
$
pageNumbers
=
'
<div class="numbers">
'
.
$
pagination
->
getLinks
(
$
_GET
).
'
</div>
'
;
// Loop through all the items in the array
foreach
(
$
productPages
as
$
productArray
) {
// Show the information about the item
echo
'
<p><b>
'
.
$
productArray
[
'
Product
'
].
'
</b> £
'
.
$
productArray
[
'
Price
'
].
'
</p>
'
;
}
// print out the page numbers beneath the results
echo
$
pageNumbers
;
}
}
?>
<hr />
<p><a href="http://www.lotsofcode.com/php/projects/php-array-pagination" target="_blank">PHP Array Pagination</a> provided by <a href="http://www.lotsofcode.com/" target="_blank">Lots of Code</a></p>
</body>
</html>
Back
|
FazBrowse Home
|
New Git URL