新闻动态

   

您现在的位置是:首页 » 新闻动态 » 网站技术


ASP 数字分页 1 2 3 4


人气: 6193  日期: 2011-03-06  作者: 大向网络  [打印本文]

数据库表:news 字段: title 搜索改下就能用了。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="Conn.asp"-->
<style>
body{ font-size:12px;}
.pages{
text-align:right;
padding-bottom:15px;
padding-right:20px;
}
.pages a:link{
display:inline;
border:1px solid #D9D9D9;
color:#001A9F;
padding:2px 5px;
margin:0px 3px;
}
.pages a:visited{
display:inline;
border:1px solid #D9D9D9;
color:#001A9F;
padding:2px 5px;
margin:0px 3px;
text-decoration:none;
}
.pages a:hover{
display:inline;
border:1px solid #8BCCEC;
color:#000000;
background:#E8F3FD;
padding:2px 5px;
margin:0px 3px;
}
.pages .click{
display:inline;
border:1px solid #ff831e;
color:#000000;
background:#ffebd9;
padding:2px 5px;
margin:0px 3px;
}
.bg{
display:inline;
border:1px solid #8BCCEC;
color:#000000;
background:#E8F3FD;
padding:2px 5px;
margin:0px 3px;
}
</style>

<table border="0" align="left" cellpadding="0" cellspacing="0">
<%
sql="select * from news "
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<tr><td colspan=9 height=40><center>暂无内容</center></td></tr>"
PageScript="ML"
else
'分页的实现
listnum=20 '每页显示20条纪录
Rs.pagesize=listnum
pageMax=rs.pagecount
listCount=rs.recordcount

page=Request("page")
if (page-pageMax) > 0 then
page=pageMax
elseif page = "" or page < 1 then
page = 1
end if
rs.absolutepage=page
'编号的实现
j=listCount
j=j-(page-1)*listnum
i=0
nn=request("page")
if nn="" then
n=0
else
nn=nn-1
n=listnum*nn
end if

do while not rs.eof and i<listnum
n=n+1
%>
<tr>
<td>
<a href="#"><%=rs("title")%></a>
</td>
</tr>
<%
rs.movenext
i=i+1
j=j-1
loop
end if
rs.close
set rs=nothing
%>
<tr class="pages" valign="middle">
<td align=right id="bottomPage">共 <%=listCount%> 条&nbsp;&nbsp;<%=listnum%> 条/页&nbsp;&nbsp;共 <%=pageMax%> 页
<% if page>1 then %>
<a href=<%=filename%>>首页</a>
<a href=<%=filename%>?page=<%=page-1%>>上一页</a>
<%else%>
<a href=<%=filename%>>首页</a>

<%end if%>
<%
pageArea=(page\10)*10
for i=pageArea-5 to pageArea+10
if i>0 and i<=pageMax then
if i=cint(page) then
response.write("<strong><font class=bg>"&i&"</font></strong>")
else
response.write("<a href="&filename&"?page="&i&">"&i&"</a>")
end if
end if
next
%>
<% if pageMax-page <> 0 then %>
<a href=<%=filename%>?page=<%=page+1%>>下一页</a>
<a href=<%=filename%>?page=<%=pageMax%>>末页</a>
<%else%>

<a href=<%=filename%>?page=<%=pageMax%>>末页</a>
<%end if%>
<select name='sldd' style='width:45px; height:20px;' onchange='location.href=this.options[this.selectedIndex].value;'>
<%
pageArea=(page\10)*10
for i=pageArea-5 to pageArea+10
if i>0 and i<=pageMax then
if i=cint(page) then %>
<option value='' selected="selected"><%=i%>页</option>
<%else%>
<option value='<%=filename%>?page=<%=i%>'><%=i%>页</option>
<%end if
end if
next
%>
</select>
</td>
</tr>
</table>


  上一篇:处理较长文章,添加 …… 效果
  下一篇:html5自带得表单验证代码 做验证再也不用那么复杂了
相关文章(Tags:数字分页,asp数字分页)