PHP 分页类代码(简单好用型)
PHP 分页类,比较简单实用的分页代码。
<div class="codetitle"><a style="CURSOR: pointer" data="51220" class="copybut" id="copybut51220" onclick="doCopy('code51220')"> 代码如下:
<div class="codebody" id="code51220">
<?PHP
// pager类
$page = $_GET;
function pager($rows,$page_size){
global $page,$select_from,$select_limit,$pagenav;
$page_count = ceil($rows/$page_size);
if($page <= 1 || $page == '') $page = 1;
if($page >= $page_count) $page = $page_count;
$select_limit = $page_size;
$select_from = ($page - 1)
$page_size.',';
$pre_page = ($page == 1)? 1 : $page - 1;
$next_page= ($page == $page_count)? $page_count : $page + 1 ;
$pagenav .= "第 $page/$page_count 页共 $rows 条记录";
$pagenav .= "首页";
$pagenav .= "前一页";
$pagenav .= "后一页";
$pagenav .= "末页";
$pagenav.=" 跳到 from test"));
pager($rows,2);
$sql = "select * from test limit $select_from $select_limit";
$rst = MysqL_query($sql);
while ($row = MysqL_fetch_array($rst)){
echo "$row[id] - $row[sex] - $row[name]
";
}
echo $pagenav;
?>