asp分页为何在第一页就全部显示完了?
详细代码:<%setconn=server.createobject("adodb.connection")conn.open("DRIVER=DriverdoMicro...
详细代码:
<%
set conn=server.createobject("adodb.connection")
conn.open("DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;pwd=;dbq="&server.mappath("example3.mdb"))
set rs=server.createobject("adodb.recordset")
sql="select * from guestbook"
rs.open sql,conn,3
rs.pagesize=20
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#0000FF" width="80%" align="center">
<tr bgcolor="#FFFFFF" align="center">
<th><%=rs(0).name%></th><th><%=rs(1).name%></th><th><%=rs(2).name%></th>
</tr>
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
i=1
while not Rs.eof
if (i mod 3)=1 then%>
<TR>
<%end if%>
<td align="center">
<a href="untitled-2.asp?id=<%=rs("id")%>"><%=RS("name")%> </a> </td>
<%if (i mod 3)=0 then%>
</TR>
<%
end if
rs.movenext
i=i+1
wend
%>
<%
next
%>
</table>
<p align="center">
<a href="example4.asp">首页</a>
<a href="example4.asp?page=<%=epage-1%>">前一页</a>
<%
if page >8 and rs.pagecount > 9 then '判断点击页大于8 并且记录集页数大于9时
if (page + 4)> rs.pagecount then '当点击页加上4 (4 的来历为 8/2) 大于 记录集是
pagenow = rs.pagecount - 8 '首次数字显示页码
else '否则
pagenow = page - 4 '点击页 减 4 (4 的来历为 8/2) 为了让点击页码
'数居中
end if
for b = 1 to 9 '每次显示9 条记录
response.write "<a href=?page="&pagenow&">"&pagenow&"</a> "
pagenow = pagenow+1
next
else
if rs.pagecount<9 then '当记录集小于9时
for b = 1 to rs.pagecount '显示数字分页码
response.write "<a href=?page="&b&">"&b&"</a> "
next
else '当记录集大于9时 但当前页小于9时 执行
for b = 1 to 9
response.write "<a href=?page="&b&">"&b&"</a> "
next
end if
end if
%>
<a href="example4.asp?page=<%=epage+1%>">后一页</a>
<a href="example4.asp?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>
<%
conn.close()
%>
请高人指点指点,看看那里出错了! 展开
<%
set conn=server.createobject("adodb.connection")
conn.open("DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;pwd=;dbq="&server.mappath("example3.mdb"))
set rs=server.createobject("adodb.recordset")
sql="select * from guestbook"
rs.open sql,conn,3
rs.pagesize=20
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#0000FF" width="80%" align="center">
<tr bgcolor="#FFFFFF" align="center">
<th><%=rs(0).name%></th><th><%=rs(1).name%></th><th><%=rs(2).name%></th>
</tr>
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
i=1
while not Rs.eof
if (i mod 3)=1 then%>
<TR>
<%end if%>
<td align="center">
<a href="untitled-2.asp?id=<%=rs("id")%>"><%=RS("name")%> </a> </td>
<%if (i mod 3)=0 then%>
</TR>
<%
end if
rs.movenext
i=i+1
wend
%>
<%
next
%>
</table>
<p align="center">
<a href="example4.asp">首页</a>
<a href="example4.asp?page=<%=epage-1%>">前一页</a>
<%
if page >8 and rs.pagecount > 9 then '判断点击页大于8 并且记录集页数大于9时
if (page + 4)> rs.pagecount then '当点击页加上4 (4 的来历为 8/2) 大于 记录集是
pagenow = rs.pagecount - 8 '首次数字显示页码
else '否则
pagenow = page - 4 '点击页 减 4 (4 的来历为 8/2) 为了让点击页码
'数居中
end if
for b = 1 to 9 '每次显示9 条记录
response.write "<a href=?page="&pagenow&">"&pagenow&"</a> "
pagenow = pagenow+1
next
else
if rs.pagecount<9 then '当记录集小于9时
for b = 1 to rs.pagecount '显示数字分页码
response.write "<a href=?page="&b&">"&b&"</a> "
next
else '当记录集大于9时 但当前页小于9时 执行
for b = 1 to 9
response.write "<a href=?page="&b&">"&b&"</a> "
next
end if
end if
%>
<a href="example4.asp?page=<%=epage+1%>">后一页</a>
<a href="example4.asp?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>
<%
conn.close()
%>
请高人指点指点,看看那里出错了! 展开
1个回答
展开全部
<!--#include file="cnn.asp"-->
<html>
<head>
<title>实验</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
set conn=server.createobject("adodb.connection")
conn.open("DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;pwd=;dbq="&server.mappath("example3.mdb"))
%>
<table width="698" height="131" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="803"><table width="120" height="4" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<table width="698" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="773" height="64"><%
Const MaxPerPage=15
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")
rs.open "select * from guestbook order by id desc",conn,1,1
if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 暂无留言!</p>"
else
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,"example4.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"example4.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"example4.asp"
end if
end if
end if
sub showContent
dim i
i=0
%>
<%if not rs.EOF and i< MaxPerPage then
colzs=3
rowzs=5
for j=1 to rowzs
if not rs.EOF then
%>
<table width="690" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<%for k=1 to colzs
if not rs.EOF and i< MaxPerPage then %>
<td width="170" valign="top"><%=rs("name")%></td>
<%rs.MoveNext
i=i+1
else%>
<td class="font1"> </td>
<%end if
next%>
</tr>
</table>
<%end if
next
end if%></td>
</tr>
</table>
<table width="698" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" height="20" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#eFeFeF" class="12font">
<form method="post" action= "<% = filename %>">
<tr>
<td height="50" valign="middle"><%
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 CurrentPage<2 Then %>
首页 上一页
<%Else %>
<a href="<% = filename %>?page=1">首页</a> <a href="<% = filename %>?page=<% = CurrentPage-1 %>">上一页</a>
<%End If
If n-currentpage<1 Then %>
下一页 末页
<%Else %>
<a href="<% = filename %>?page=<% = (CurrentPage+1) %>">下一页</a> <a href="<% = filename %>?page=<% = n %>">末页</a>
<%End If %>
第<b><% = CurrentPage %></b>页, 共<b><% = n %></b>页, 共<b><% = totalnumber %></b>条留言, 每页<b><% = maxperpage %></b>条留言
<%End Function%></td>
</tr>
</form>
</table></td>
</tr>
</table>
<table width="120" height="4" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<html>
<head>
<title>实验</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
set conn=server.createobject("adodb.connection")
conn.open("DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;pwd=;dbq="&server.mappath("example3.mdb"))
%>
<table width="698" height="131" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="803"><table width="120" height="4" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<table width="698" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="773" height="64"><%
Const MaxPerPage=15
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")
rs.open "select * from guestbook order by id desc",conn,1,1
if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 暂无留言!</p>"
else
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,"example4.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"example4.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"example4.asp"
end if
end if
end if
sub showContent
dim i
i=0
%>
<%if not rs.EOF and i< MaxPerPage then
colzs=3
rowzs=5
for j=1 to rowzs
if not rs.EOF then
%>
<table width="690" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<%for k=1 to colzs
if not rs.EOF and i< MaxPerPage then %>
<td width="170" valign="top"><%=rs("name")%></td>
<%rs.MoveNext
i=i+1
else%>
<td class="font1"> </td>
<%end if
next%>
</tr>
</table>
<%end if
next
end if%></td>
</tr>
</table>
<table width="698" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" height="20" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#eFeFeF" class="12font">
<form method="post" action= "<% = filename %>">
<tr>
<td height="50" valign="middle"><%
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 CurrentPage<2 Then %>
首页 上一页
<%Else %>
<a href="<% = filename %>?page=1">首页</a> <a href="<% = filename %>?page=<% = CurrentPage-1 %>">上一页</a>
<%End If
If n-currentpage<1 Then %>
下一页 末页
<%Else %>
<a href="<% = filename %>?page=<% = (CurrentPage+1) %>">下一页</a> <a href="<% = filename %>?page=<% = n %>">末页</a>
<%End If %>
第<b><% = CurrentPage %></b>页, 共<b><% = n %></b>页, 共<b><% = totalnumber %></b>条留言, 每页<b><% = maxperpage %></b>条留言
<%End Function%></td>
</tr>
</form>
</table></td>
</tr>
</table>
<table width="120" height="4" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询