关于翻页的问题
<%@ LANGUAGE="VBScript" %><script language="VBScript" runat="server" ></script>
<html>
<head></head>
<body>
<center>
<%
Sub ShowHeader(tabletitle)
Response.Write("<p>【<b>" & tabletitle & "</b>】")
Response.Write("<table border='1' width='80%'>")
Response.Write("<tr align='left'>")
Response.Write("<th width='25%'>会员账号</th>")
Response.Write("<th width='25%'>球队名称</th>")
Response.Write("<th width='25%'>会员积分</th>")
Response.Write("<th width='25%'>会员头衔</th>")
Response.Write("</tr>")
End Sub
bh = Request("hyzh")
qm = Request("qmlm")
if bh <> "" then
' 注释:生成SQL查询语句
if qm <> "" then
mysql = "SELECT main.会员账号,main.会员积分,main.会员头衔,team.球队名称 " & _
" FROM main " & _
" INNER JOIN team ON main.球迷联盟= team.球队编号 " & _
" WHERE 会员账号 LIKE '%" & Request("hyzh") & "%'" & _
" AND 球迷联盟 = '" & Left(Request("qmlm"),3) & "'"
' 注释:连接数据库
Set objRS = Session("objRS")
objRS.Source = mysql
objRS.Open
' 注释:显示查询结果
' 注释:此处为分页查询
If objRS.RecordCount > 0 Then
If Request("ps") = "" Then
objRS.PageSize = 10
Else
objRS.PageSize = CInt(Request("ps"))
End If
If Request("pn") = "" Then
CurPage = 1
Else
CurPage = CInt(Request("pn"))
End if
objRS.AbsolutePage = CurPage
' 注释:显示分页信息
Response.Write("共有【" & objRS.RecordCount & "】条记录")
' 注释:制作分页导航
If objRS.PageCount > 1 Then
Response.Write(",分成【" & objRS.PageCount & "】页:")
For i = 1 to objRS.PageCount
If i = CurPage Then Response.Write("<b>")
%>
<a href="search2.asp?pn=<% =i %>">第<% =i %>页</a>>
<%
If i = CurPage Then Response.Write("</b>")
Next
End If
Call ShowHeader("会员信息")
Do While Not objRS.EOF
Response.Write("<tr>")
Response.Write("<td>" & objRS("会员账号") & "</td>")
Response.Write("<td>" & objRS("球队名称") & "</td>")
Response.Write("<td>" & objRS("会员积分") & "</td>")
Response.Write("<td>" & objRS("会员头衔") & "</td>")
Response.Write("</tr>")
objRS.MoveNext
Loop
End If
else
mysql = "SELECT main.会员账号,main.会员积分,main.会员头衔,team.球队名称 " & _
" FROM main " & _
" INNER JOIN team ON main.球迷联盟= team.球队编号 " & _
" WHERE 会员账号 LIKE '%" & Request("hyzh") & "%'"
' 注释:连接数据库
Set objRS = Session("objRS")
objRS.Source = mysql
objRS.Open
' 注释:显示查询结果
' 注释:此处为分页查询
If objRS.RecordCount > 0 Then
If Request("ps") = "" Then
objRS.PageSize = 10
Else
objRS.PageSize = CInt(Request("ps"))
End If
If Request("pn") = "" Then
CurPage = 1
Else
CurPage = CInt(Request("pn"))
End if
objRS.AbsolutePage = CurPage
' 注释:显示分页信息
Response.Write("共有【" & objRS.RecordCount & "】条记录")
' 注释:制作分页导航
If objRS.PageCount > 1 Then
Response.Write(",分成【" & objRS.PageCount & "】页:")
For i = 1 to objRS.PageCount
If i = CurPage Then Response.Write("<b>")
%>
<a href="search2.asp?pn=<% =i %>">第<% =i %>页</a>>
<%
If i = CurPage Then Response.Write("</b>")
Next
End If
Call ShowHeader("会员信息")
Do While Not objRS.EOF
Response.Write("<tr>")
Response.Write("<td>" & objRS("会员账号") & "</td>")
Response.Write("<td>" & objRS("球队名称") & "</td>")
Response.Write("<td>" & objRS("会员积分") & "</td>")
Response.Write("<td>" & objRS("会员头衔") & "</td>")
Response.Write("</tr>")
objRS.MoveNext
Loop
End If
end if
else
mysql = "SELECT main.会员账号,main.会员积分,main.会员头衔,team.球队名称 " & _
" FROM main " & _
" INNER JOIN team ON main.球迷联盟= team.球队编号 " & _
" WHERE 球迷联盟 = '" & Left(Request("qmlm"),3) & "'"
Set objRS = Session("objRS")
objRS.Source = mysql
objRS.Open
If objRS.RecordCount > 0 Then
If Request("ps") = "" Then
objRS.PageSize = 10
Else
objRS.PageSize = CInt(Request("ps"))
End If
If Request("pn") = "" Then
CurPage = 1
Else
CurPage = CInt(Request("pn"))
End if
objRS.AbsolutePage = CurPage
' 注释:显示分页信息
Response.Write("共有【" & objRS.RecordCount & "】条记录")
' 注释:制作分页导航
If objRS.PageCount > 1 Then
Response.Write(",分成【" & objRS.PageCount & "】页:")
For i = 1 to objRS.PageCount
If i = CurPage Then Response.Write("<b>")
%>
<a href="srerch2.asp?pn=<% =i %>">第<% =i %>页</a>>
<%
If i = CurPage Then Response.Write("</b>")
Next End If
Call ShowHeader("商品信息登记表")
For i = 1 To objRS.RecordCount
Response.Write("<tr>")
Response.Write("<td>" & objRS("会员账号") & "</td>")
Response.Write("<td>" & objRS("球队名称") & "</td>")
Response.Write("<td>" & objRS("会员积分") & "</td>")
Response.Write("<td>" & objRS("会员头衔") & "</td>")
Response.Write("</tr>")
objRS.MoveNext
Next
End If
end if
' 注释:关闭记录集
objRS.Close
Set objRS = Nothing
%>
</center>
</body>
</html>
显示第一页的时候还正常,要是翻到第二页的话就显示的是全部信息了~~~~
asp.rar
(11.71 KB)
我把附件上传了,希望高手帮我看下~~~~~
少上传了一个文件 补上
global.rar
(799 Bytes)
[[it] 本帖最后由 xiaolaba3330 于 2008-6-19 23:09 编辑 [/it]]