一个google类似的分页 学习版

访问以url方式:

http://localhost/learn/lesson/page.php?cur=16&nums=50

1 <?php
2  $page_current = $_GET['cur'];
3 $page_nums = $_GET['nums'];
4
5 //prev
6 if($page_current != 0){
7 echo '前一页';
8 }
9
10 //1,2,3
11 for($i=$page_current - 10, $end = $page_current + 10; $i< $end; $i++){
12 if($i<=0) continue;
13 if($i>$page_nums) break;
14 if($i == $page_current){
15 echo ' ['.$i.'] ';
16 }else{
17 echo ' '.$i.' ';
18 }
19 }
20
21 //next
22 if($page_current != $page_nums){
23 echo '下一页';
24 }

 

posted @ 2010-11-10 15:18  wingle  阅读(177)  评论(0编辑  收藏  举报