您好,欢迎访问一九零五行业门户网

PHP实现阿里巴巴实现同类产品翻页效果_PHP教程

当前页左边的页码为最新的产品,按更新时间呈升序排列;右边的页码为早期的产品, 按更新时间呈降序排列。如果左边的记录条数小于$space(页码区段)的值,页码$start从1开始向右增值。如果左则的记录条数多于$left(左右各显示页数)的值,$start将从左边记录数减去$left值开始记数。
copy to clipboard引用的内容:[www.bkjia.com]1 space = $num;
14 $this->left = ceil(($num-1)/2);
15 }
16
17 public function setdb(&$db) {
18 $this->db = $db;
19 }
20
21 public function setpagename($pagename) {
22 $this->pagename = $pagename;
23 }
24
25 public function getpages($catid, $exptime) {
26 $fields = array(`id`,`title`);
27 $left = array(> => array(exptime=>$exptime), memberid => gs(_mem_prefix_ . memberid), catid=>$catid);
28 $right = array( array(exptime=>$exptime), memberid => gs(_mem_prefix_ . memberid), catid=>$catid);
29
30 $leftcount = $this->db->getcount($left);
31
32 if($leftcount left) {
33 $star = 1;
34 $leftlimit = limit . $leftcount;
35 $rightlimit = limit . ($this->space-$leftcount);
36 }
37 else {
38 $start = $leftcount - $this->left;
39 $leftlimit = limit . $this->left;
40 $rightlimit = $leftlimit;
41 }
42
43 $list1 = $this->db->findall($left, array(exptime=>asc), $leftlimit, $fields);
44 $list2 = $this->db->findall($right, array(exptime=>desc), $rightlimit, $fields);
45
46 /** 上一页链接 **/
47 $c = count($list1);
48 if($c > 1) {
49 $url = $this->pagename.-.$list1[$c]['id']..html;
50 $pages = 上一页;
51 }elseif($c == 1) {
52 $url = $this->pagename.-.$list1[0]['id']..html;
53 $pages = 上一页;
54 }else {
55 $pages = ;
56 }
57
58
59 /** 当前页的左边内容 **/
60 foreach($list1 as $item) {
61 $url = $this->pagename.-.$item['id']..html;
62 $pages .= {$start};
63 $start++;
64 }
65
66 $pages .= {$leftcount};
67 $start++;
68
69 /** 当前页面右边的内容 **/
70 foreach($list1 as $item) {
71 $url = $this->pagename.-.$item['id']..html;
72 $pages .= {$start};
73 $start++;
74 }
75
76 /** 下一页的链接 **/
77 $c = count($list2);
78 if($c > 0) {
79 $url = $this->pagename.-.$list2[0]['id']..html;
80 $pages .= 下一页;
81 }else {
82 $pages .= ;
83 }
84
85 return $pages;
86 }
87 };
88 ?>
http://www.bkjia.com/phpjc/364468.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/364468.htmltecharticle当前页左边的页码为最新的产品,按更新时间呈升序排列;右边的页码为早期的产品, 按更新时间呈降序排列。如果左边的记录条数小于...
其它类似信息

推荐信息