如何用PHP+MYSQL+SMARTY+HTML实现留言板的分页,重要的是想知道思路,最好粗略解释下为什么?
$smarty->assign("recordcount",$recordcount);//总记录数$smarty->assign("page",$page);//当前页...
$smarty -> assign("recordcount", $recordcount);//总记录数
$smarty -> assign("page", $page); //当前页
$smarty -> assign("pagecount", $pagecount); //总页数
$smarty -> assign("prepage", $page-1); //上一页
$smarty -> assign("nexpage", $page+1); //下一页
$smarty -> assign("numpage", $numpage); //数字分页
$smarty -> assign("fpage", $fpage); //要分页的网页
如何用HTML把这些功能组织到一起实现分页呢? 展开
$smarty -> assign("page", $page); //当前页
$smarty -> assign("pagecount", $pagecount); //总页数
$smarty -> assign("prepage", $page-1); //上一页
$smarty -> assign("nexpage", $page+1); //下一页
$smarty -> assign("numpage", $numpage); //数字分页
$smarty -> assign("fpage", $fpage); //要分页的网页
如何用HTML把这些功能组织到一起实现分页呢? 展开
展开全部
给你一个自写的分页的函数:
function listpage($xydwpage, $table, $page_size, $lid){
global $page;
echo"
<SCRIPT language=JavaScript>
function Pagejump(value)
{
if(value!= '') {
window.location=('$xydwpage?page='+value);
}
}
</SCRIPT>";
if($lid==""){
$whe="";
} else {
$whe=" WHERE lid=$lid";
}
if( isset($page) ){
$page = intval($page);
}
else{
$page = 1;
}
$row = xydwsql("SELECT count(*) as amount FROM $table$whe");
$amount = $row[0];
if($amount ){
if( $amount < $page_size ){ $page_count = 1; }
if( $amount % $page_size ){
$page_count = (int)($amount / $page_size) + 1;
}else{
$page_count = $amount / $page_size;
}
}
else{
$page_count = 0;
}
for($i=1;$i<$page_count+1;$i++){
$i == $page ? $select=" selected" : $select="";
$opt.="<option value={$i}$select>{$i}</option>";
}
$page_string="Totals :{$page_count} pages <select onchange=Pagejump(this.options[this.selectedIndex].value)>{$opt}</select>";
return $page_string;
}
function listpage($xydwpage, $table, $page_size, $lid){
global $page;
echo"
<SCRIPT language=JavaScript>
function Pagejump(value)
{
if(value!= '') {
window.location=('$xydwpage?page='+value);
}
}
</SCRIPT>";
if($lid==""){
$whe="";
} else {
$whe=" WHERE lid=$lid";
}
if( isset($page) ){
$page = intval($page);
}
else{
$page = 1;
}
$row = xydwsql("SELECT count(*) as amount FROM $table$whe");
$amount = $row[0];
if($amount ){
if( $amount < $page_size ){ $page_count = 1; }
if( $amount % $page_size ){
$page_count = (int)($amount / $page_size) + 1;
}else{
$page_count = $amount / $page_size;
}
}
else{
$page_count = 0;
}
for($i=1;$i<$page_count+1;$i++){
$i == $page ? $select=" selected" : $select="";
$opt.="<option value={$i}$select>{$i}</option>";
}
$page_string="Totals :{$page_count} pages <select onchange=Pagejump(this.options[this.selectedIndex].value)>{$opt}</select>";
return $page_string;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询