八分页列表实例
时间:2007-02-17 来源:PHP爱好者
<?
$conn = @mysql_connect('localhost:3306','test','test');
include_once "js.class.php";
include_once "pager.class.php";
include_once "whxbb.class.php";
include_once "whxbb_article.class.php";
// 以上代码最好全放在一个包含文件中
<?
/* 分页显示文章列表,每页10条 */
$article = new WHXBB_Article();
$info = $article->GetNInfo(10, $page);
$pager = $article->pager;
if (WHXBB::isError($info))
new WHXBB_Error("读取文章信息失败,请您稍后再试", 1, WHXBB_ERROR_ECHO);
else if($info == 0)
new WHXBB_Error("没有任何您需要的信息", 2, WHXBB_ERROR_ECHO);
else
{
for ($i = 0; $i <count($info); $i++)
{
$arr = $info[$i];
?>
<p><a href="read.php?id=<?=$arr['id']?>"><?=$arr['title']?></a> - 作者: <?=$arr['author']?></p>
<?
}
}
if (WHXBB::isPager($pager))
{
echo " 共" . $pager->infoCount . "条纪录 ";
echo " 共" . $pager->pageCount . "页 ";
echo " 当前页:" . $pager->pageNo;
if ($pager->pageNo != 1)
echo " <a href=list.php?page=1>首页</a> ";
if ($pager->GotoPrevPage())
echo " <a href=list.php?page=" . $pager->prevPageNo . ">上一页</a> ";
if ($pager->GotoNextPage())
echo " <a href=list.php?page=" . $pager->nextPageNo . ">下一页</a> ";
if ($pager->pageNo != $pager->pageCount)
echo " <a href=list.php?page=" . $pager->pageCount . ">末页</a> ";
}
@mysql_close($conn);
?>
php爱好者站 http://www.phpfans.net PHP|MySQL|javascript|ajax|html.
$conn = @mysql_connect('localhost:3306','test','test');
include_once "js.class.php";
include_once "pager.class.php";
include_once "whxbb.class.php";
include_once "whxbb_article.class.php";
// 以上代码最好全放在一个包含文件中
<?
/* 分页显示文章列表,每页10条 */
$article = new WHXBB_Article();
$info = $article->GetNInfo(10, $page);
$pager = $article->pager;
if (WHXBB::isError($info))
new WHXBB_Error("读取文章信息失败,请您稍后再试", 1, WHXBB_ERROR_ECHO);
else if($info == 0)
new WHXBB_Error("没有任何您需要的信息", 2, WHXBB_ERROR_ECHO);
else
{
for ($i = 0; $i <count($info); $i++)
{
$arr = $info[$i];
?>
<p><a href="read.php?id=<?=$arr['id']?>"><?=$arr['title']?></a> - 作者: <?=$arr['author']?></p>
<?
}
}
if (WHXBB::isPager($pager))
{
echo " 共" . $pager->infoCount . "条纪录 ";
echo " 共" . $pager->pageCount . "页 ";
echo " 当前页:" . $pager->pageNo;
if ($pager->pageNo != 1)
echo " <a href=list.php?page=1>首页</a> ";
if ($pager->GotoPrevPage())
echo " <a href=list.php?page=" . $pager->prevPageNo . ">上一页</a> ";
if ($pager->GotoNextPage())
echo " <a href=list.php?page=" . $pager->nextPageNo . ">下一页</a> ";
if ($pager->pageNo != $pager->pageCount)
echo " <a href=list.php?page=" . $pager->pageCount . ">末页</a> ";
}
@mysql_close($conn);
?>
php爱好者站 http://www.phpfans.net PHP|MySQL|javascript|ajax|html.
相关阅读 更多 +