'############################### 定义变量 ########################################
set rs=server.CreateObject("adodb.recordset")
sql="select * from gongqiou where sontypeid="&sontypeid
sql=sql&" order by ID desc"
rs.open sql,conn,3,2
rs_count=rs.recordcount
sizepage=3
if rs.eof then
response.Redirect("read.asp")
Response.End
end if
'################################## 格式参数 ##########################################
if currentpage="" then currentpage=1 end if
if (currentpage*sizepage)>rs_count then
if (rs_count mod sizepage)=0 then
currentpage= (rs_count\ sizepage)
else
crrentpage= (rs_count \sizepage)+1
end if
end if
'################################ 移动指钟 #############################
if currentpage=1 then
rs.MoveFirst
else
rownum=(currentpage-1)*sizepage
if rownum < rs_count then
rs.Move rownum
else
Response.Write "没有记录了!"
Response.End
end if
<% '######################## 翻页 ################################
if currentpage >1 then %>
<font color="#FF6600" size="2"><a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=1">首页</a>
<a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=<%=(currentpage-1)%>">上一页</a> </font>
<% else%>
<font color="#FF6600" size="2">首页
上一页 </font>
<%
end if
if (rs_count mod sizepage) =0 then
last= rs_count\sizepage
else
last=(rs_count \sizepage)+1
end if
if currentpage >= last then %>
<font color="#FF6600" size="2">下一页
尾页 </font>
<%else%> <font color="#FF6600" size="2"><a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=<%=(currentpage+1)%>">下一页</a>
<a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=<%=last%>">尾页 </a></font>
<% end if%>
<font color="#6633FF" size="2">一共有<%=last%>页,这是第<%=currentpage%>页 一共有<%=rs_count%>条信息</font>
</body>
</html>
<% rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%'开始分页
Const MaxPerPage=12
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
if namekey="" then
.....
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"editdingdan.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"editdingdan.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"editdingdan.asp"
end if
end if
end if
sub showContent
dim i
i=0
%>
...... <%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</table>
<%
End Sub
Function showpage(totalnumber,maxperpage,filename)
Dim n
If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If
'//////////////////
if namekey="" then
Response.Write "<form method=Post action="&filename&"?zhuangtai="&zhuangtai&">"
else
Response.Write "<form method=Post action="&filename&"?zhuangtai="&zhuangtai&"&namekey="&namekey&">"
end if
'//////////////////
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
'///////////////////
if namekey="" then
Response.Write "<a href="&filename&"?page=1&zhuangtai="&zhuangtai&" class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="¤tPage-1&"&zhuangtai="&zhuangtai&" class='contents'>上一页</a> "
ELSE
Response.Write "<a href="&filename&"?page=1&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="¤tPage-1&"&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>上一页</a> "
end if
'//////////////////
End If
If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
'////////////////////////
if namekey="" then
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&zhuangtai="&zhuangtai&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&zhuangtai="&zhuangtai&" class='contents'>尾页</a>"
else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>尾页</a>"
end if
'/////////////////////
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"笔订单 "&maxperpage&"笔订单/页</font> "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"
Response.Write " <input type='submit' class='contents' value='GO' name='cndok'></form>"
End Function
%>
<html>
<title>分页技术</title>
<head>
<%
const MaxPerPage=25
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
%>
</head>
<body bgcolor=Thistle>
<P align=center><FONT face=方正舒体><FONT size=5><STRONG>实例
分页技术</STRONG>
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'> ERROR!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
</FONT></FONT></P>
<P>PAGE <%=currentpage%> OF <%=n%> 共<%=rs.recordcount%> 纪录
<% k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='index.asp?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(k-1)+"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='index.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(n)+"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
%>
</P>
<TABLE border=1 align=center>
<tr>
<%
for i= 0 to howmanyfields%>
<TD><B><%=rs(i).name%></B></TD>
<%
next
i=0
do while not rs.eof and i<maxperpage%>
<tr align=middle>
<%for j=0 to howmanyfields%>
<td>
<%=rs(j)%>
</td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</TABLE>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>