求助!!!asp查询分页第一页正确,第二页起为全部内容
详细代码如下
<!--#include file="conn.asp"-->
<%dim adminlogin
adminlogin=session("adminlogin")
if adminlogin<>true then
response.write("<script language='javascript'>")
response.write("alert('您没有登录,请登录!');")
response.write("adminlogin.asp")
response.write("</Script>")
response.end
end if%>
<%
if session("userqx") <> 00 and session("userqx")<>11 then
response.write "对不起 您无权访问本页"
response.end
session.timeout=5
Session.Abandon
Response.redirect("adminlogin.asp")
end if
%>
<%
dim action,ksh1,xm1,sfzh1
call search()
%>
<%
dim pages,Curpage
pages=Trim(request.form("pages"))
Curpage=request("curpage")
if pages="" then
If curpage = "" or curpage < 0 then
Curpage=1
Else
Curpage=cint(curpage)
End if
else
curpage=cint(pages)
end if
dim i,id,rs,objRs
i=1
sub search()
ksh1=request("ksh1")
sfzh1=request("sfzh1")
xm1=request("xm1")
if ksh1="" and sfzh1="" and xm1="" then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk")'/*记录统计
elseif ksh1<>"" and len(ksh1)=11 and sfzh1="" and xm1="" then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] where ksh='"&ksh1&"' order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk where ksh='"&ksh1&"'")'/*记录统计
elseif ksh1="" and sfzh1="" and xm1<>"" then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] where xm like '%"&xm1&"%' order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk where xm like '%"&xm1&"%'")'/*记录统计
elseif ksh1="" and sfzh1<>"" and len(sfzh1)=18 and xm1="" then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] where sfzh='"&sfzh1&"' order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk where sfzh='"&sfzh1&"'")'/*记录统计
elseif ksh1<>"" and len(ksh1)=11 and sfzh1<>"" and len(sfzh1)=18 and xm1="" then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] where ksh='"&ksh1&"' and sfzh='"&sfzh1&"' order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk where ksh='"&ksh1&"' and sfzh='"&sfzh1&"'")'/*记录统计
elseif ksh1<>"" and len(ksh1)=11 and xm1<>"" and sfzh1="" then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] where ksh='"&ksh1&"' and xm like '%"&xm1&"%' order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk where ksh='"&ksh1&"' and xm like '%"&xm1&"%'")'/*记录统计
elseif ksh1="" and sfzh1<>"" and len(sfzh1)=18 and xm1<>"" then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] where xm like '%"&xm1&"%' and sfzh='"&sfzh1&"' order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk where xm like '%"&xm1&"%' and sfzh='"&sfzh1&"'")'/*记录统计
elseif ksh1<>"" and len(ksh1)=11 and xm1<>"" and sfzh1<>"" and len(sfzh1)=18 then
sql="select xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf from [ckbmk] where ksh='"&ksh1&"' and xm like '%"&xm1&"%' and sfzh='"&sfzh1&"' order by cknf desc,mid(ksh,7,5) asc"
Set objRs=Conn.Execute("Select count(*) From ckbmk where bmh='"&bmh1&"' and xm like '%"&xm1&"%' and sfzh='"&sfzh1&"'")'/*记录统计
else
response.write("<script language='javascript'>")
response.write("alert('您输入的考生号或身份证号位数不足,请返回!');")
response.write("history.go(-1);")
response.write("</Script>")
response.end
end if
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof then
response.write("<script language='javascript'>")
response.write("alert('没有您要查询的信息,请返回!');")
response.write("adminlogin.asp")
response.write("</Script>")
response.end
rs.close
end if
end sub
dim xm,xb,sfzh,mz,kstz,bkcc,bkkl,ysyz,bkzy,zslb,zsbyz,ksh,jxd,jtd,cknf
set xm=rs(0)
set xb=rs(1)
set sfzh=rs(2)
set mz=rs(3)
set kstz=rs(4)
set bkcc=rs(5)
set bkkl=rs(6)
set ysyz=rs(7)
set bkzy=rs(8)
set zslb=rs(9)
set zsbyz=rs(10)
set ksh=rs(11)
set jxd=rs(12)
set jtd=rs(13)
set cknf=rs(14)
rs.PageSize=20
if CurPage>rs.Pagecount then
CurPage=rs.Pagecount
end if
rs.AbsolutePage=CurPage
%>
<p align="center"><b><font size="4">成人高考考生报名信息</font></b></p>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber2">
<form method="POST" action="style_ckbm.asp?action=search" name=frmAnnounce >
<tr>
<td width="4%" height="30" align="center"><font size="2">考生号</font></td>
<td width="32%" height="30">
<input type="text" name="ksh1" size="16" onKeyUp="value=value.replace(/[^\d| ]/g,'')"><font color="#FF0000" size="2">*10位数字,前四位为0122,且不能包含空格。</font></td>
<td width="3%" height="30">
<p align="center"><font size="2">姓名</font></td>
<td width="10%" height="30">
<input type="text" name="xm1" size="16" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\u4E00-\u9FA5]/g,''))"></td>
<td width="5%" height="30">
<font size="2">身份证号</font></td>
<td width="46%" height="30">
<input type="text" name="sfzh1" size="20" onKeyUp="value=value.replace(/[^\d|x| ]/g,'')"><font color="#FF0000" size="2">*18位数字或字母,不能包含空格。若最后一位为字母,该字母请大写。</font></td>
</tr>
<tr>
<td width="100%" height="30" align="center" colspan="6"><input type="submit" value="查询" name="B1"></td>
</tr>
</form>
</table>
</center>
</div>
<p></p>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="76">
<tr>
<td width="8%" align="center" height="44"><b><font size="2">考生号</font></b></td>
<td width="5%" align="center" height="44"><b><font size="2">姓名</font></b></td>
<td width="3%" align="center" height="44"><b><font size="2">性别</font></b></td>
<td width="12%" align="center" height="44"><b><font size="2">身份证号</font></b></td>
<td width="9%" align="center" height="44"><b><font size="2">报考类别</font></b></td>
<td width="5%" align="center" height="44"><b><font size="2">报考层次</font></b></td>
<td width="11%" align="center" height="44"><b><font size="2">报考专业</font></b></td>
<td width="5%" align="center" height="44"><b><font size="2">民族</font></b></td>
<td width="3.5%" align="center" height="44"><b><font size="2">特征</font></b></td>
<td width="3.5%" align="center" height="44"><b><font size="2">语种</font></b></td>
<td width="7%" align="center" height="44"><b><font size="2">招生类别</font></b></td>
<td width="6%" align="center" height="44"><b><font size="2">专升本是否通过认证</font></b></td>
<td width="7%" align="center" height="44"><b><font size="2">集体点</font></b></td>
<td width="4%" align="center" height="44"><b><font size="2">教学点</font></b></td>
<td width="5%" align="center" height="44"><b><font size="2">成考年份</font></b></td>
<td width="6%" align="center" height="44"><b><font size="2">操作</font></b></td>
</tr>
<%do while not rs.eof and (i<=20)
i=i+1%>
<tr>
<td width="8%" align="center" height="20"><font size="2"><%=ksh%> </font></td>
<td width="5%" align="center" height="20"><font size="2"><%=xm%> </font></td>
<td width="3%" align="center" height="20"><font size="2"><%=xb%> </font></td>
<td width="12%" align="center" height="20"><font size="2"><%=sfzh%> </font></td>
<td width="9%" align="center" height="20"><font size="2"><%=bkkl%> </font></td>
<td width="5%" align="center" height="20"><font size="2"><%=bkcc%> </font></td>
<td width="11%" align="center" height="20"><font size="2"><%=bkzy%> </font></td>
<td width="5%" align="center" height="20"><font size="2"><%=mz%> </font></td>
<td width="3.5%" align="center" height="20"><font size="2"><%=kstz%> </font></td>
<td width="3.5%" align="center" height="20"><font size="2"><%=ysyz%> </font></td>
<td width="7%" align="center" height="20"><font size="2"><%=zslb%> </font></td>
<td width="6%" align="center" height="20"><font size="2"><%=zsbyz%> </font></td>
<td width="7%" align="center" height="20"><font size="2"><%=jtd%> </font></td>
<td width="4%" align="center" height="20"><font size="2"><%=jxd%> </font></td>
<td width="5%" align="center" height="20"><font size="2"><%=cknf%> </font></td>
<td width="6%" align="center" height="20"><a href="charge_ckbm.asp?action=del&ksh=<%=rs(11)%>&sfzh=<%=rs(2)%>&cknf=<%=rs(14)%>" onClick="return confirm('您确定要删除<%=cknf%>年的考生号<%=ksh%>身份证号<%=sfzh%>考生的成人高考报名信息吗?')">
<font size="2">删除</font></a><font size="2">
<a href="edit_ckbm.asp?ksh=<%=rs(11)%>&sfzh=<%=rs(2)%>&cknf=<%=rs(14)%>" onClick="return confirm('您确定要修改<%=cknf%>年的考生号<%=ksh%>身份证号<%=sfzh%>考生的成人高考报名信息吗?')">
修改</a></font></td>
</tr>
<%rs.movenext
loop%>
</table>
<font size="2">共</font><font size="2" color="#FF0000"><%response.write(objRs(0))%></font><font size="2">条记录。页次(</font><font size="2" color="#FF0000"><%=CurPage%></font><font size="2">/</font><font size="2" color="#FF0000"><%=rs.PageCount%></font><font size="2">)<%if CurPage-1>=1 then%><a target="_self" href="style_ckbm.asp?CurPage=<%=CurPage-1%>">
<<上一页 </a><%end if%>
<%if CurPage+1<=rs.Pagecount then%><a target="_self" href="style_ckbm.asp?CurPage=<%=CurPage+1%>">下一页>></a>
</font></font></p>
<p style="margin-top: 3px"><b><font size="2"> 教学点代码:</font></b><font size="2" color="#FF0000">20-重庆医药卫校,30-涪陵一职中(天原化工),40-涪陵信息技术学校</font><br>
</p>
<%end if%><%
objRs.Close '/*记录统计
Set objRs=Nothing '/*记录统计
rs.close
set rs=nothing
conn.Close
Set conn = Nothing
%>
[解决办法]
<a target="_self" href="style_ckbm.asp?CurPage=<%=CurPage+1%>">下一页</a>
因为你只传了页数,没有把当前页使用的参数传过去。
你应该改成类似这样的
<a target="_self" href="style_ckbm.asp?CurPage=<%=CurPage+1%>&ksh1=<%=ksh1%>&sfzh1=<%=sfzh1%>&xm1=<%=xm1%>">下一页</a>