代码如下 | 复制代码 |
2 3 4 5 6 7 102 103 104 105 106 用户留言如下:107 108 109 110 111
8 $page = (isset($_request['page'])) ? $_request['page'] : 1; 9 $offset = ($page - 1) * $num; 10 $result = mysql_query("select count(*) from client"); 11 $total = mysql_fetch_row($result); 12 $total = $total[0]; 13 $pagenum = ceil($total / $num); 14 $page = min($pagenum, $page); //获得首页 15 $prepg = $page - 1; //上一页 16 if ($prepg <= 1) 17 $prepg = 1; 18 $nextpg = ($page == $pagenum ? 1 : $page + 1); //下一页 19 //如果只有一页则跳出函数: 20 if ($pagenum <= 1) 21 return false; 22 23 $sql = "select `name`,`content` from `client` limit " . $offset . "," . $num; 24 $res = mysql_query($sql); 25 while ($content = mysql_fetch_row($res)) { 26 $con .= " 27 } 28 $con .= " 29 $con .= <<< page 30 31 32 page; 33 34 echo $con; 35 ?> |