asp分页显示问题
215个首页上一页下一页尾页页次:1/11页20条记录/页结果显示正确,可是点下一页就页面无法打开了<!--#includefile="../Connections/co...
215个 首页 上一页 下一页 尾页 页次:1/11页 20条记录/页
结果显示正确,可是点下一页就页面无法打开了
<!--#include file="../Connections/conn.asp" -->
<%
dim totalPut
dim CurrentPage
dim TotalPages
dim MaxPerPage
MaxPerPage=20
dim connect
set connect=server.CreateObject ("adodb.connection")
connect.Open MM_conn_STRING
dim rs
set rs=server.CreateObject ("adodb.recordset")
dim name,institue,specialty
name = request.querystring("textname")
institue = request.querystring("textinstitue")
specialty = request.querystring("textspecialty")
sql = "select name,institue,specialty from new_infor_student"
select case name
case "" sql=sql & " WHERE"
case else sql=sql & " WHERE name like '%"&name&"%' and"
end select
if institue<>"" then
sql=sql & " institue='"&institue&"'"
end if
if specialty <>"" then
sql=sql & " and specialty='"&specialty&"'"
end if
rs.Open sql,connect,1,1
%>
<%
if rs.recordcount=0 then
%>
<div align="center" class="style3">没有查询记录!</div>
<%
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,"search.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"search.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"search.asp"
end if
end if
rs.close
end if
sub showContent
dim i
i=0
%>
<table border="1" width="100%">
<tr>
<td>姓名</td>
<td>专业</td>
<td>学院</td>
</tr>
<%do until rs.EOF%>
<tr>
<td><%=rs("name")%></td>
<td><%=rs("specialty")%></td>
<td><%=rs("institue")%></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<%
end sub
%>
未完待续
<%if n-currentpage<1 then
response.write "下一页 尾页"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
response.write " <b>"&maxperpage&"</b>条记录/页 "
end function
%> 展开
结果显示正确,可是点下一页就页面无法打开了
<!--#include file="../Connections/conn.asp" -->
<%
dim totalPut
dim CurrentPage
dim TotalPages
dim MaxPerPage
MaxPerPage=20
dim connect
set connect=server.CreateObject ("adodb.connection")
connect.Open MM_conn_STRING
dim rs
set rs=server.CreateObject ("adodb.recordset")
dim name,institue,specialty
name = request.querystring("textname")
institue = request.querystring("textinstitue")
specialty = request.querystring("textspecialty")
sql = "select name,institue,specialty from new_infor_student"
select case name
case "" sql=sql & " WHERE"
case else sql=sql & " WHERE name like '%"&name&"%' and"
end select
if institue<>"" then
sql=sql & " institue='"&institue&"'"
end if
if specialty <>"" then
sql=sql & " and specialty='"&specialty&"'"
end if
rs.Open sql,connect,1,1
%>
<%
if rs.recordcount=0 then
%>
<div align="center" class="style3">没有查询记录!</div>
<%
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,"search.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"search.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"search.asp"
end if
end if
rs.close
end if
sub showContent
dim i
i=0
%>
<table border="1" width="100%">
<tr>
<td>姓名</td>
<td>专业</td>
<td>学院</td>
</tr>
<%do until rs.EOF%>
<tr>
<td><%=rs("name")%></td>
<td><%=rs("specialty")%></td>
<td><%=rs("institue")%></td>
</tr>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<%
end sub
%>
未完待续
<%if n-currentpage<1 then
response.write "下一页 尾页"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&">"
response.write "下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
response.write " <b>"&maxperpage&"</b>条记录/页 "
end function
%> 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询