文章列表分页代码(列表页分页标签)
admin 发布:2022-12-19 20:50 129
今天给各位分享文章列表分页代码的知识,其中也会对列表页分页标签进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
php文章列表分页问题
给你个分页类吧,这个好用.也简单.
//文件名Page.class.php
?php
class Pager{
/**
*int总页数
**/
protected $pageTotal;
/**
*int上一页
**/
protected $previous;
/**
*int下一页
**/
protected $next;
/**
*int中间页起始序号
**/
protected $startPage;
/**
*int中间页终止序号
**/
protected $endPage;
/**
*int记录总数
**/
protected $recorbTotal;
/**
*int每页显示记录数
**/
protected $pageSize;
/**
*int当前显示页
**/
protected $currentPage;
/**
*string基url地址
**/
protected $baseUri;
/**
*@returnstring获取基url地址
*/
public function getBaseUri(){
return $this-baseUri;
}
/**
*@returnint获取当前显示页
*/
public function getCurrentPage(){
return $this-currentPage;
}
/**
*@returnint获取每页显示记录数
*/
public function getPageSize(){
return $this-pageSize;
}
/**
*@returnint获取记录总数
*/
public function getRecorbTotal(){
return$this-recorbTotal;
}
/**
*@paramstring$baseUri设置基url地址
*/
public function setBaseUri($baseUri){
$this-baseUri=$baseUri;
}
/**
*@paramint$currentPage设置当前显示页
*/
public function setCurrentPage($currentPage){
$this-currentPage=$currentPage;
}
/**
*@paramint$pageSize设置每页显示记录数
*/
public function setPageSize($pageSize){
$this-pageSize=$pageSize;
}
/**
*@paramint$recorbTotal设置获取记录总数
*/
public function setRecorbTotal($recorbTotal){
$this-recorbTotal=$recorbTotal;
}
/**
*构造函数
**/
public function __construct()
{
$this-pageTotal=0;
$this-previous=0;
$this-next=0;
$this-startPage=0;
$this-endPage=0;
$this-pageSize=20;
$this-currentPage=0;
}
/**
*分页算法
**/
private function arithmetic(){
if($this-currentPage1)
$this-currentPage=1;
$this-pageTotal=floor($this-recorbTotal/$this-pageSize)+($this-recorbTotal%$this-pageSize0?1:0);
if($this-currentPage1$this-currentPage$this-pageTotal)
header('location:'.$this-baseUri.'page='.$this-pageTotal);
$this-next=$this-currentPage+1;
$this-previous=$this-currentPage-1;
$this-startPage=($this-currentPage+5)$this-pageTotal?$this-pageTotal-10:$this-currentPage-5;
$this-endPage=$this-currentPage5?11:$this-currentPage+5;
if($this-startPage1)
$this-startPage=1;
if($this-pageTotal$this-endPage)
$this-endPage=$this-pageTotal;
}
/**
*分页样式
**/
protected function pageStyle(){
$result="共".$this-pageTotal."页 ";
if($this-currentPage1)
$result.="a href=\"".$this-baseUri."page=1\"第1页/a a href=\"".$this-baseUri."page=$this-previous\"前一页/a";
else
$result.="第1页 ";
for($i=$this-startPage;$i=$this-endPage;$i++){
if($this-currentPage==$i)
$result.="$i";
else
$result.=" a href=\"".$this-baseUri."page=$i\"$i/a ";
}
if($this-currentPage!=$this-pageTotal){
$result.="a href=\"".$this-baseUri."page=$this-next\"后一页/a";
$result.=" a href=\"".$this-baseUri."page=$this-pageTotal\"最后1页/a";
}else{
$result.=" 最后1页";
}
return $result;
}
/**
*执行分页
**/
public function execute(){
if($this-baseUri!=""$this-recorbTotal==0)
return"";
$this-arithmetic();
return $this-pageStyle();
}
}
?
//上边是类
//在HTML中调用方法
//先查出数据库中的总合
?php
require("../inc/conn.php");
include_once("../js/Pager.class.php");
$sql="select * from content order by id desc";
$rs = mysql_query($sql);
$pager = new Pager();
$pageno = $_GET["page"];
if ($pageno == "")
{
$pageno = 1;
}
$pagesize = 10;
$startno = ($pageno-1) * $pagesize;
$recordcount = mysql_num_rows($rs);
$sql = "select * from content order by id desc limit $startno,$pagesize";
$rs = mysql_query($sql);
//$count=mysql_num_rows($rs);
$i = 1;
while($rows = mysql_fetch_assoc($rs))
{
//这里边是循环体,不用说应该知道吧
}
//这底下的执行分页
?php
if(isset($_GET['page']))
{
$pager-setCurrentPage($_GET["page"]);
}
else
{
$pager-setCurrentPage(1);
}
$pager-setPageSize($pagesize);
$pager-setRecorbTotal($recordcount);
$pager-setBaseUri("news.php?");
echo $pager-execute();
?
如何制作文章列表分页效果?
table width="100%" height="601" border="0" cellpadding="0" cellspacing="0"
tr
td width="69%" height="12" valign="top"/td
/tr
tr
td height="589" valign="top"table width="100%" border="0" cellspacing="0" cellpadding="0"
tr
tdtable width="100%" border="0" cellpadding="0" cellspacing="0" id="weizi"
tr
td height="20"关于我们 -span class="rightbt"%=request("tea_arttype")%/span/td
/tr
tr
td background="images/btline.jpg" style="height:2px"/td
/tr
/table/td
/tr
tr
tdbr
%
set rs = server.createobject("adodb.recordset")
tea_arttype=request("tea_arttype")
if tea_arttype="" then
sql="select * from tea_data order by id desc"
else
sql="select * from tea_data where tea_arttype = '" tea_arttype "' order by id desc"
end if
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.write "暂无新闻"
else
%
table width="91%" height="20" border="0" align="center" cellpadding="0" cellspacing="0"
tr
td width="680" height="20"table width="100%" height="27" border="0" align="center" cellpadding="0" cellspacing="0"
tr align="center"
%
dim curpage,j
if request("page")="" then
curpage = 1
else
curpage = cint(request("page"))
end if rs.pagesize = 17
rs.absolutepage = curpage for j = 1 to rs.pagesize
%
td width="680" height="27" valign="middle"table width="100%" height="24" border="0" cellpadding="0" cellspacing="0" background="images/xuxian.gif"
tr
td width="82%" height="24" class="tdline" img src="images/bot.jpg" width="9" height="9" / a href="show.asp?id=%=rs("id")%" target="_blank"%=rs("tea_topic")%/a/td
td width="18%" align="center" class="tdline"font color="#5D5C5C"(%=rs("tea_time")%)/font/td
/tr
/table/td
%
if (j mod 1)=0 then response.write "/trtrtd/td/trtr align='center' background='images/probg.jpg'"
rs.movenext
if rs.eof then
j = j + 1
exit for
end if
next
%
/tr
/table/td
/tr
/table
div align="left" class="12font"
form action="" method="post"
%
response.write "center"
response.write "第font color=red" + cstr(curpage) + "/font页/总" + cstr(rs.pagecount) + "页 "
response.write "每页显示"rs.pagesize"个,总共有" + cstr(rs.recordcount) + "条信息 "
if curpage = 1 then
response.write "首页 前页 "
else
response.write "a href='" request.ServerVariables("script_name") "?lx=" request("lx") "page=1'首页/a a href='" request.ServerVariables("script_name") "?lx=" request("lx") "page=" + cstr(curpage-1) + "'前页/a "
end if
if curpage = rs.pagecount then
response.write "后页 末页"
else
response.write "a href='" request.ServerVariables("script_name") "?lx=" request("lx") "page=" + cstr(curpage+1) + "'后页/a a href='" request.ServerVariables("script_name") "?lx=" request("lx") "page=" + cstr(rs.pagecount) + "'末页/a" end if
end if %
转:
select name='page' size='1' onchange='javascript:submit()' class="text1"
%for i = 1 to cint(rs.pagecount)%
option value='%=i%' %if cint(request("page"))=cint(i) then% selected="selected" %end if%第%=i%页/option
%next%
/select
/form
/div
%rs.close
set rs=nothing%/td
/tr
/table/td
/tr
/table
怎么样在列表页中输入页码就可以跳转到指定的分页
想要在文章列表页下面的页码中输入指定的页码就可以跳转到指定的页面中,要怎么样做?
很多人都想在文章的列表页有这样的功能,其实修改这个也很简单的,按照下面的步骤就可以了:
编辑打开列表页模板,默认路径为\templets\default\list_article.htm,
将下列代码插入head/head之间,也可以做JS调用。
script type="text/javascript"// ![CDATA[
function onCheckPage(){
var beginPage = parseInt(document.beginPagefrm.beginPage.value);
if(isNaN(beginPage)){
alert("请输入数字!");
return false;
}
if(beginPage = 0 ) { beginPage = 1; } if(beginPage 100){
beginPage = 100;
}
if(beginPage 1 ) {
document.beginPagefrm.action = "list_{dede:field name='typeid'/}_" + beginPage + ".html";
} else {
document.beginPagefrm.action = "{dede:type typeid=’0′ row=1}[field:typelink /]{/dede:type}";
}
return true;
}
/script
下面的是列表页的分页代码,替换原来的分页代码,测试过有效,具体的显示样式自己调整。
div class="dede_pages"
ul class="pagelist"
form name="beginPagefrm" method=post action="" onsubmit="return onCheckPage()"
{dede:pagelist listitem="index,end,pre,next,pageno" listsize="5"/}直接到第input size=4 name="beginPage" value=""页input type="submit" name="Submit" value="前住"
/form
/ul
/div
php静态文章列表分页的问题,求大神指教,详解。
1.关于浏览器显示不一样:是因为自身的这段代码存在语法错误,请用echo ,逐行检查。
或者删除所有的代码。逐行在粘贴检查.
目前我发现.if($i == 0;{ 这个地方有错误.
2.这个分页有自身的一些规则.比如分页文件.page_1.htm代码第一页.先把分页的内容提取出来生成列表,并保存在page_1.htm ,第2页保存在page_2.htm....以此类推
3.channel和$channelid 根据字面以及常用文章数据表的设计,这个应该是频道,也就是说是提取某一个频道下面的文章。
如何给列表页分页
列表页使用标签list调去文章然后使用分页标签{dede:pagelist listitem="info,index,end,pre,next,pageno" listsize="5"/}
list标签
{dede:list col='' titlelen='' infolen='' imgwidth='' imgheight='' listtype='' orderby='' pagesize='' orderway=''}{/dede:list}
参数说明:
col='' 内容列数
titlelen='' 标题长度
infolen='' 内容摘要长度
imgwidth='' 缩略图宽
imgheight='' 缩略图高
orderby='' 排序方式,有效的排序方式有 senddate、pubdate、id、click、lastpost、postnum ,默认为 sortrank
pagesize='20' 分页大小
分页标签
{dede:pagelist listsize='5' listitem=''/}
参数说明:
listsize 表示 [1][2][3] 这些项的长度 x 2
listitem 表示页码样式,可以把下面的值叠加
index首页
pre 上一页
pageno 页码
next 下一页
end 末页
option 下拉跳转框
关于文章列表分页代码和列表页分页标签的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
相关推荐
- 05-17怎么宣传网站,怎么宣传网站文章
- 05-16软文怎么写比较吸引人,软文怎么写比较吸引人的文章
- 05-09网页代码,网页代码快捷键
- 05-07企业推广软文范文,企业推广文章
- 05-06单页网站的代码(完整的网页代码)[20240506更新]
- 05-06个人主页图片代码(个人主页图片代码怎么弄)[20240506更新]
- 05-06提取微信名片代码(微信名片信息提取)[20240506更新]
- 05-06php后台权限管理代码(php管理员权限)[20240506更新]
- 05-06付费观看代码php(付费观看代码)[20240506更新]
- 05-06在线html执行代码(html怎么运行)[20240506更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接