急!ASP分页代码问题,为什么第一页显示正常,点下一页就会报错?
我的代码如下,请各位大虾帮忙改改!一经答对,立即给分!<!--#includefile="conn.asp"--><%dimpagepage=Request.QueryS...
我的代码如下,请各位大虾帮忙改改!一经答对,立即给分!
<!--#include file="conn.asp"-->
<%
dim page
page = Request.QueryString("page")
if page="" then page=1
page2 = Request.QueryString("k")
if page2="" then page2=1
action = Request.QueryString("action")
action_e = Request.Form("action_e")
dim gbcount,n,x,y,j,k
n=20
x=20
set rs = conn.execute("select COUNT(*) as gbcount From wstj")
gbcount=rs("gbcount")
rs.close
if gbcount/n = int(gbcount/n) then y=int(gbcount/n)
else
y=int(gbcount/n)+1
end if
if (page2)*x > y then
k=y
else
k=(page2)*x
end if
if page=1 then
j=""
else
j="where id not in (select top "&n*(page-1)&" id from wstj Order By xh Desc)"
end if
Set Rs = Server.CreateObject("ADODB.RecordSet")
Sql="select top "&n&" * From wstj where bt <> '' "&j&" Order By xh Desc"
Rs.Open Sql,Conn,1,1
%>
<span class="texthei">
<% if rs.bof and rs.eof then Response.Write "当前没有记录" %>
</span>
<%
dim lou,words,reply,email,qq,web,come
if Request.QueryString("page")<2 then
lou=gbcount
else
lou=gbcount-((Request.QueryString("page")-1)*n)
end if
%><table width="1000" border="0" align="center" cellpadding="1" cellspacing="3" bgcolor="#FFFFFF">
<tr>
<td colspan="6"><div align="center" class="STYLE6 STYLE9">已提交事件</div></td>
</tr>
<tr>
<td colspan="6"><div align="center">
<hr />
</div></td>
</tr>
<tr>
<td> </td>
<td><div align="center" class="STYLE12">标题</div></td>
<td><div align="center" class="STYLE12">姓名</div></td>
<td><div align="center" class="STYLE12">时间</div></td>
<td><div align="center" class="STYLE12">是否已处理</div></td>
<td><%do while not rs.eof%></td>
</tr>
<tr>
<td width="49"> </td>
<td width="287"><div align="center"><%=left(rs("bt"),15)%></div></td>
<td width="167"><div align="center"><%=rs("name")%></div></td>
<td width="171"><div align="center"><%=rs("fqsj")%></div></td>
<td width="171"><div align="center"><%=rs("bz")%></div></td>
<td width="88"> </td>
</tr>
<tr>
<td colspan="6">
<%
rs.movenext
loop
%>
</td>
</tr>
<tr>
<td colspan="6"><hr /></td>
</tr>
还有部分代码,紧接着上面:
<tr>
<td colspan="6"><div align="center">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="20" align="right" class="unnamed1"> 有<%=gbcount %>条留言 共<%=y %>页 分页
<% if page2>1 then %>
<a href="index.asp?page=<%=((page2-1)*x)-(x-1) %>&k=<%=page2-1%>">前<%=x%>页</a>
<% end if %>
<% For m =((page2)*x)-(x-1) To k %>
[<a href="wstj-d.asp?page=<%=m%>&k=<%=page2%>"><%=m%></a>]
<%
Next
%>
<% if page2*x < y then %>
<a href="wstj-d.asp?page=<%=((page2+1)*x)-(x-1)%>&k=<%=page2+1%>">后<%=x%>页</a>
<% end if %>
</td>
</tr>
<% if len(webtitle)>2 then %>
<tr>
<td height="20" align="right" class="unnamed1"><marquee onmouseout="start();" onmouseover="stop();" scrollamount="3">
<%=webtitle %>
</marquee></td>
</tr>
<% end if %>
</table>
</div></td>
</tr>
</table>
<p>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</p> 展开
<!--#include file="conn.asp"-->
<%
dim page
page = Request.QueryString("page")
if page="" then page=1
page2 = Request.QueryString("k")
if page2="" then page2=1
action = Request.QueryString("action")
action_e = Request.Form("action_e")
dim gbcount,n,x,y,j,k
n=20
x=20
set rs = conn.execute("select COUNT(*) as gbcount From wstj")
gbcount=rs("gbcount")
rs.close
if gbcount/n = int(gbcount/n) then y=int(gbcount/n)
else
y=int(gbcount/n)+1
end if
if (page2)*x > y then
k=y
else
k=(page2)*x
end if
if page=1 then
j=""
else
j="where id not in (select top "&n*(page-1)&" id from wstj Order By xh Desc)"
end if
Set Rs = Server.CreateObject("ADODB.RecordSet")
Sql="select top "&n&" * From wstj where bt <> '' "&j&" Order By xh Desc"
Rs.Open Sql,Conn,1,1
%>
<span class="texthei">
<% if rs.bof and rs.eof then Response.Write "当前没有记录" %>
</span>
<%
dim lou,words,reply,email,qq,web,come
if Request.QueryString("page")<2 then
lou=gbcount
else
lou=gbcount-((Request.QueryString("page")-1)*n)
end if
%><table width="1000" border="0" align="center" cellpadding="1" cellspacing="3" bgcolor="#FFFFFF">
<tr>
<td colspan="6"><div align="center" class="STYLE6 STYLE9">已提交事件</div></td>
</tr>
<tr>
<td colspan="6"><div align="center">
<hr />
</div></td>
</tr>
<tr>
<td> </td>
<td><div align="center" class="STYLE12">标题</div></td>
<td><div align="center" class="STYLE12">姓名</div></td>
<td><div align="center" class="STYLE12">时间</div></td>
<td><div align="center" class="STYLE12">是否已处理</div></td>
<td><%do while not rs.eof%></td>
</tr>
<tr>
<td width="49"> </td>
<td width="287"><div align="center"><%=left(rs("bt"),15)%></div></td>
<td width="167"><div align="center"><%=rs("name")%></div></td>
<td width="171"><div align="center"><%=rs("fqsj")%></div></td>
<td width="171"><div align="center"><%=rs("bz")%></div></td>
<td width="88"> </td>
</tr>
<tr>
<td colspan="6">
<%
rs.movenext
loop
%>
</td>
</tr>
<tr>
<td colspan="6"><hr /></td>
</tr>
还有部分代码,紧接着上面:
<tr>
<td colspan="6"><div align="center">
<table width="550" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="20" align="right" class="unnamed1"> 有<%=gbcount %>条留言 共<%=y %>页 分页
<% if page2>1 then %>
<a href="index.asp?page=<%=((page2-1)*x)-(x-1) %>&k=<%=page2-1%>">前<%=x%>页</a>
<% end if %>
<% For m =((page2)*x)-(x-1) To k %>
[<a href="wstj-d.asp?page=<%=m%>&k=<%=page2%>"><%=m%></a>]
<%
Next
%>
<% if page2*x < y then %>
<a href="wstj-d.asp?page=<%=((page2+1)*x)-(x-1)%>&k=<%=page2+1%>">后<%=x%>页</a>
<% end if %>
</td>
</tr>
<% if len(webtitle)>2 then %>
<tr>
<td height="20" align="right" class="unnamed1"><marquee onmouseout="start();" onmouseover="stop();" scrollamount="3">
<%=webtitle %>
</marquee></td>
</tr>
<% end if %>
</table>
</div></td>
</tr>
</table>
<p>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</p> 展开
5个回答
展开全部
<a href="index.asp?page=<%=((page2-1)*x)-(x-1) %>&k=<%=page2-1%>">前<%=x%>页</a>
在这个分页的时候页面后面少传了一个参数,
都改成<a href="index.asp?page=<%=((page2-1)*x)-(x-1) %>&k=<%=page2-1%>&id<%=rs("id")%>"前<%=x%>页</a>
当然是数据库里面有ID这个字段,如果没有就改成别的。
还有就是你这个分页不是很好,
在这个分页的时候页面后面少传了一个参数,
都改成<a href="index.asp?page=<%=((page2-1)*x)-(x-1) %>&k=<%=page2-1%>&id<%=rs("id")%>"前<%=x%>页</a>
当然是数据库里面有ID这个字段,如果没有就改成别的。
还有就是你这个分页不是很好,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
再加点分。呵呵,我帮你修改修改
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这个分页的怎么这么乱啊。。可以考虑换个简单的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Function Html_Page_Code(Rs_All_Count,Per_Record,Per_Pag)
'##########################################################################################################
'###############(参数Per_Pag每页页面数,Per_Record每页展示记录数,Rs_All_Count所查询记录总数)################
'##########################################################################################################
Page_Number = 0
Page_Code = ""
Page_All_Count = ""
Page_All_Count = Int(Rs_All_Count/Per_Record)
Mod_Number = Int(Rs_All_Count mod Per_Record)
Create_Mod_Number = Int(Rs_All_Count mod Per_Record)
If Mod_Number = 0 Then
Page_Max_Size = Int(Page_All_Count)
Else
Page_Max_Size = Int(Page_All_Count + 1)
End If
Start_Page_Number = Absolute_Page_Number
Next_Page_Number = Absolute_Page_Number + 1
Virtual_Start_Page_Number = Absolute_Page_Number - Per_Pag
Virtual_Last_Page_Number = Absolute_Page_Number + Per_Pag
IF Virtual_Start_Page_Number < 1 then
Virtual_Start_Page_Number = 1
END IF
IF Virtual_Last_Page_Number > Page_Max_Size then
Virtual_Last_Page_Number = Page_Max_Size
END IF
IF Absolute_Page_Number <= Page_Max_Size then
For K_Count = Virtual_Start_Page_Number to Virtual_Last_Page_Number
if K_Count > 0 AND K_Count <= Page_Max_Size then
Page_Code = Page_Code & "<DIV Class='Page_Class'>"
Page_Code = Page_Code & "<a href='" & K_Count & ".html'>" & K_Count &"</a>"&" "
Page_Code = Page_Code & "</DIV>"
end if
Next
Frist_Page_Code = Frist_Page_Code & "<DIV Class='Page_Class'>"
Frist_Page_Code = Frist_Page_Code & "<a href='" & "1.html'>" & "首页" &"</a>"&" "
Frist_Page_Code = Frist_Page_Code & "</DIV>"
Last_Page_Code = Last_Page_Code & "<DIV Class='Page_Class'>"
Last_Page_Code = Last_Page_Code & "<a href='" & Page_Max_Size & ".html'>" & "尾页" &"</a>"&" "
Last_Page_Code = Last_Page_Code & "</DIV>"
Last_Page_Code = Last_Page_Code & "<DIV Class='Page_All'>页面 "
Last_Page_Code = Last_Page_Code & Absolute_Page_Number & " / " & Page_Max_Size
Last_Page_Code = Last_Page_Code & "</DIV>"
Page_Code = Frist_Page_Code & Page_Code & Last_Page_Code
END IF
End Function
<a href="http://www.webnong.com" class="Strong_Green">西安网站建设</a>
'##########################################################################################################
'###############(参数Per_Pag每页页面数,Per_Record每页展示记录数,Rs_All_Count所查询记录总数)################
'##########################################################################################################
Page_Number = 0
Page_Code = ""
Page_All_Count = ""
Page_All_Count = Int(Rs_All_Count/Per_Record)
Mod_Number = Int(Rs_All_Count mod Per_Record)
Create_Mod_Number = Int(Rs_All_Count mod Per_Record)
If Mod_Number = 0 Then
Page_Max_Size = Int(Page_All_Count)
Else
Page_Max_Size = Int(Page_All_Count + 1)
End If
Start_Page_Number = Absolute_Page_Number
Next_Page_Number = Absolute_Page_Number + 1
Virtual_Start_Page_Number = Absolute_Page_Number - Per_Pag
Virtual_Last_Page_Number = Absolute_Page_Number + Per_Pag
IF Virtual_Start_Page_Number < 1 then
Virtual_Start_Page_Number = 1
END IF
IF Virtual_Last_Page_Number > Page_Max_Size then
Virtual_Last_Page_Number = Page_Max_Size
END IF
IF Absolute_Page_Number <= Page_Max_Size then
For K_Count = Virtual_Start_Page_Number to Virtual_Last_Page_Number
if K_Count > 0 AND K_Count <= Page_Max_Size then
Page_Code = Page_Code & "<DIV Class='Page_Class'>"
Page_Code = Page_Code & "<a href='" & K_Count & ".html'>" & K_Count &"</a>"&" "
Page_Code = Page_Code & "</DIV>"
end if
Next
Frist_Page_Code = Frist_Page_Code & "<DIV Class='Page_Class'>"
Frist_Page_Code = Frist_Page_Code & "<a href='" & "1.html'>" & "首页" &"</a>"&" "
Frist_Page_Code = Frist_Page_Code & "</DIV>"
Last_Page_Code = Last_Page_Code & "<DIV Class='Page_Class'>"
Last_Page_Code = Last_Page_Code & "<a href='" & Page_Max_Size & ".html'>" & "尾页" &"</a>"&" "
Last_Page_Code = Last_Page_Code & "</DIV>"
Last_Page_Code = Last_Page_Code & "<DIV Class='Page_All'>页面 "
Last_Page_Code = Last_Page_Code & Absolute_Page_Number & " / " & Page_Max_Size
Last_Page_Code = Last_Page_Code & "</DIV>"
Page_Code = Frist_Page_Code & Page_Code & Last_Page_Code
END IF
End Function
<a href="http://www.webnong.com" class="Strong_Green">西安网站建设</a>
参考资料: http://www.webnong.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询