学习地址:http://www.imooc.com/video/2463
=$totalPage)$page=$totalPage;//$offset=($page-1)*$pageSize;//$sql="select * from imooc_admin limit {$offset},{$pageSize}";////echo $sql;//$rows=fetchAll($sql);////print_r($rows);//foreach($rows as $row){// echo "编号:".$row['id'],"";// echo "管理员的名称:".$row['username'],"
";//}//echo showPage($page,$totalPage);//echo "
";//echo showPage($page,$totalPage,"cid=5&pid=6");function showPage($page,$totalPage,$where=null,$sep=" "){ $where=($where==null)?null:"&".$where; $url = $_SERVER ['PHP_SELF']; $index = ($page == 1) ? "首页" : "首页"; $last = ($page == $totalPage) ? "尾页" : "尾页"; $prevPage=($page>=1)?$page-1:1; $nextPage=($Page>=$totalPage)?$totalPage:$page+1; $prev = ($page == 1) ? "上一页" : "上一页"; $next = ($page == $totalPage) ? "下一页" : "下一页"; $str = "总共{ $totalPage}页/当前是第{ $page}页"; for($i = 1; $i <= $totalPage; $i ++) { //当前页无连接 if ($page == $i) { $p .= "[{ $i}]"; } else { $p .= "[{ $i}]"; } } $pageStr=$str.$sep . $index .$sep. $prev.$sep . $p.$sep . $next.$sep . $last; return $pageStr;}