<? $rs=new COM("adodb.recordset"); $rs->open("select * from [article] order by [articleid]",$conn,1,3); $rs->pagesize=5; $page=trim($_GET['page']); if($page=="" || is_numeric(intval($page))<=0){$page=1;}else if(intval($page)>$rs->pagecount){$page=$rs->pagecount;} $page=intval($page); if(!$rs->eof||$rs->bof){ $rs->absolutepage=$page; $mypagesize=$rs->pagesize; $i=$rs->recordCount()-($page-1)*$rs->pagesize; while(!$rs->eof && $mypagesize>0 && $i>=$rs->recordCount()-1-$rs->pagesize*$page){ $articleid = $rs->Fields(0)->value; $articletitle = $rs->Fields(1)->value; ?> <li><a href="detail.php?id=<? echo $articleid; ?>"><? echo $articletitle; ?></a><span><? echo $articlei; ?></span></li> <? $rs->movenext; $mypagesize--; $i--; } } ?> <a href="index.php?page=1">头页</a> <a href="index.php?page=<? if($page>1){echo $page-1;}else{echo 1;}?>">上页</a> <a href="index.php?page=<? if($page<$rs->pagecount){echo $page+1;}else{echo $rs->pagecount;}?>">下页</a> <a href="index.php?page=<? echo $rs->pagecount;?>">尾页</a> 共<? echo $rs->recordCount(); ?>篇文章,分<? echo $rs->pagecount;?>页显示,现在是第<? echo $page;?>页