The page number to the left of the current page is the latest product, sorted in ascending order by update time, and the page number on the right is the earlier product, sorted in descending order of update time. If the number of record bars on the left is less than the value of $space (page segment), the page number $start increment from 1 to the right. If the number of records on the left is greater than the value of $left (the left and right pages), $start will start counting from the left record minus the $left value.
Copy to ClipboardWhat to refer to: [www.bkjia.com]1 2/** to achieve the same product page **/
3
4
5 Class Pager
6 {
7 protected $space;
8 protected $left;
9 protected $DB;
Ten protected $pageName;
11
Public Function Setspace ($num) {
$this->space = $num;
$this->left = Ceil (($num-1)/2);
15}
16
Public Function Setdb (& $db) {
$this->db = $db;
19}
20
Public Function Setpagename ($pageName) {
$this->pagename = $pageName;
23}
24
Public Function GetPages ($catid, $exptime) {
$fields = Array ("' id ', ' title '");
$left = Array (">" = = Array ("exptime" = = $exptime), "MemberID" = GS (_mem_prefix_. "MemberID"), "catid" and "= $catid);
$right = Array ("<" = = Array ("Exptime" and "= $exptime"), "MemberID" = GS (_mem_prefix_. "MemberID"), "catid" and "= $catid);
29
$leftCount = $this->db->getcount ($left);
31
if ($leftCount <= $this->left) {
$star = 1;
$leftLimit = "LIMIT". $leftCount;
$rightLimit = "LIMIT". ($this->space-$leftCount);
36}
Notoginseng else {
$start = $leftCount-$this->left;
$leftLimit = "LIMIT". $this->left;
$rightLimit = $leftLimit;
41}
42
$list 1 = $this->db->findall ($left, Array ("exptime" = "ASC"), $leftLimit, $fields);
$list 2 = $this->db->findall ($right, Array ("exptime" = "DESC"), $rightLimit, $fields);
45
46/** Prev Link **/
$c = count ($list 1);
if ($c > 1) {
$url = $this->pagename. " -". $list 1[$c [' id '].". HTML ";
$pages = "Previous Page"
";
Wuyi}elseif ($c = = 1) {
$url = $this->pagename. " -". $list 1[0][' id '].". HTML ";
$pages = "Previous page
";
}else {
$pages = "";
56}
57
58
59/** The left content of the current page **/
($list 1 as $item) {
$url = $this->pagename. " -". $item [' id '].". HTML ";
$pages. = "
- {$start}
";
$start + +;
64}
65
$pages. = "
- {$leftCount}
";
$start + +;
68
69/** content to the right of the current page **/
($list 1 as $item) {
$url = $this->pagename. " -". $item [' id '].". HTML ";
$pages. = "
- {$start}
";
$start + +;
74}
75
76/** next page link **/
$c = count ($list 2);
if ($c > 0) {
$url = $this->pagename. " -". $list 2[0][' id '].". HTML ";
$pages. = "Next page
";
Bayi}else {
$pages. = "";
83}
84
$pages of the return;
86}
87};
?>
http://www.bkjia.com/PHPjc/364468.html www.bkjia.com true http://www.bkjia.com/PHPjc/364468.html techarticle the page number to the left of the current page is the latest product, sorted in ascending order by update time, and the page number on the right is the earlier product, sorted in descending order of update time. If the number of record bars on the left is less than ...
-