主题:多条件查询+分页(点分页链接就显示全部记录)
多条件查询+分页(点分页链接就显示全部记录),请朋友们帮忙给看看哪里出问题了
<%
bzr=Session("UserName")
strSql = "SELECT * FROM class WHERE mainteacher='"&bzr&"'"
Set rs11 = Server.CreateObject("ADODB.Recordset")
rs11.open strSql,conn,1,1
bj=rs11("name")
%>
<table width="808" style="border-collapse: collapse" height="37">
<form id="form1" name="form1" id="form1" method="post" action="Index_Student_kq.asp" target="_self">
<td width="796" bgcolor="#6699FF" height="37" align="center" colspan="16">
选择班级:
<select name="classid" size="1">
<%
strSql = "SELECT * FROM Class WHERE name='"&bj&"'"
Set rs111 = Server.CreateObject("ADODB.Recordset")
rs111.open strSql,conn,1,1
%>
<%
Do While Not rs111.EOF
%>
<option value=<%=rs111("name")%> selected><%=rs111("name")%></option>
<%
rs111.movenext
loop
rs111.close
%>
</select> 学期: <select name="xq" size="1">
<option value=1 selected>第一学期</option>
<option value="2">第二学期</option>
<option value="3">第三学期</option>
<option value="4">第四学期</option>
<option value="5">第五学期</option>
</select>
科目:<select name="Kc" size="1">
<%
strSql = "SELECT * FROM suject"
Set rs222 = Server.CreateObject("ADODB.Recordset")
rs222.open strSql,conn,1,1
%><%
Do While Not rs222.EOF
%>
<option value="<%=rs222("name")%>" selected><%=rs222("name")%></option>
<%
rs222.movenext
loop
rs222.close
%>
</select>
<select name="By" size="1">
<option value="zp">总评成绩</option>
<option value="bukao1">第一次补考</option>
<option value="bukao2">第二次补考</option>
<option value="bukao3">第三次补考</option>
</select>
<select name="By0" size="1">
<option value="全部">全部</option>
<option value="及格">及格</option>
<option value="不及格">不及格</option>
</select>
<%
Dim strSearchSql ,strKc ,strBy ,strBj ,strBy0,strxq
strBy = Request.form("By")
strBy0 = Request.form("By0")
strBj = trim(Request.form("classid"))
strKc = Request.form("Kc")
strxq = Request.form("xq")
If strBj <> "" And strBy <> "" and strKc <> "" and strby0 <> "" Then
If strBy = "zp" and strby0 = "全部" Then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"'"
elseIf strBy = "zp" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen > 59"
elseIf strBy = "zp" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen < 60"
elseIf strBy = "bukao1" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 > 59"
elseIf strBy = "bukao1" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 < 60"
elseIf strBy = "bukao2" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 > 59"
elseIf strBy = "bukao2" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 < 60"
elseIf strBy = "bukao3" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 > 59"
elseIf strBy = "bukao3" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 < 60"
Else
strSearchSql = "WHERE "& strBy &" = '"& strBj &"' and kemu = '"& strKc &"'"
End If
Else
strSearchSql = "WHERE class = '"& bj &"'"
End If
Dim rs,rs11,rs22 ,strSql ,Num ,pageNum ,page ,loopNum
strSql = "SELECT * FROM Student_cj " & strSearchSql
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql,conn,3,3
'if request("search")="搜索" or isempty(session("str")) then
'session("str")=strSql
'end if
'rs.open session("str"),conn,1,1
%>
<%
If rs.recordcount > 0 Then
rs.pagesize = 14
Num = rs.recordcount
pageNum = rs.pagecount
page = Request.QueryString("page")
If page <> "" Then
page = Cint(page)
ElseIf page < 1 Then
page = 1
Else
page =1
End If
If page < 1 then
page =1
End If
If page*rs.pagesize >Num and Not ((page-1)*rs.pagesize <Num) Then
page = 1
End If
rs.absolutepage = page
If page <> pageNum Then
LoopNum = rs.pagesize
Else
LoopNum = Num - (page-1)*rs.pagesize
End If
%><input type="submit" name="search" value="搜索"/>
</td>
</form></table></table>
</td>
<% For i = 1 to LoopNum %>
记录显示部分
<% rs.movenext
Next %>
<tr>
<td colspan="16" bgcolor="#B3CBFF" width="0" height="23"><div align="center">
总共找到<%=Num%>条记录 <a href="index_student_kq.asp?page=1"><font color="#0000FF">首页</font></a><font color="#0000FF"> </font><a href="index_student_kq.asp?page=<%=page-1%>"><font color="#0000FF">上一页</font></a><font color="#0000FF"> </font[color=FF0000]><a href="index_student_kq.asp?page=<%=page+1%>&xueqi=<%=strxq%>&kemu=<%=strkc%>"><[/color]font color="#0000FF">下一页</font></a><font color="#0000FF"> </font><a href="index_student_kq.asp?page=<%=pageNum%>"><font color="#0000FF">尾页</font></a> 页次:<%=page%>/<%=pagenum%> 共<%=pageNum%>页</div></td>
</tr>
<tr>
<td colspan="16" bgcolor="#C2A6FF" width="0" height="20">
<p align="center">
<input type="submit" name="Submit" value=" 进入添加所选中学生的考勤次数 " style="border: 1pt solid #EEEEEE">
<input type="reset" name="Submit2" value=" 重新选择 " style="border: 1pt solid #EEEEEE"></td>
</tr>
</table>
<%
Else
%>
<p align="center">没有相关记录!</td>
<%
End If
%>
<%
bzr=Session("UserName")
strSql = "SELECT * FROM class WHERE mainteacher='"&bzr&"'"
Set rs11 = Server.CreateObject("ADODB.Recordset")
rs11.open strSql,conn,1,1
bj=rs11("name")
%>
<table width="808" style="border-collapse: collapse" height="37">
<form id="form1" name="form1" id="form1" method="post" action="Index_Student_kq.asp" target="_self">
<td width="796" bgcolor="#6699FF" height="37" align="center" colspan="16">
选择班级:
<select name="classid" size="1">
<%
strSql = "SELECT * FROM Class WHERE name='"&bj&"'"
Set rs111 = Server.CreateObject("ADODB.Recordset")
rs111.open strSql,conn,1,1
%>
<%
Do While Not rs111.EOF
%>
<option value=<%=rs111("name")%> selected><%=rs111("name")%></option>
<%
rs111.movenext
loop
rs111.close
%>
</select> 学期: <select name="xq" size="1">
<option value=1 selected>第一学期</option>
<option value="2">第二学期</option>
<option value="3">第三学期</option>
<option value="4">第四学期</option>
<option value="5">第五学期</option>
</select>
科目:<select name="Kc" size="1">
<%
strSql = "SELECT * FROM suject"
Set rs222 = Server.CreateObject("ADODB.Recordset")
rs222.open strSql,conn,1,1
%><%
Do While Not rs222.EOF
%>
<option value="<%=rs222("name")%>" selected><%=rs222("name")%></option>
<%
rs222.movenext
loop
rs222.close
%>
</select>
<select name="By" size="1">
<option value="zp">总评成绩</option>
<option value="bukao1">第一次补考</option>
<option value="bukao2">第二次补考</option>
<option value="bukao3">第三次补考</option>
</select>
<select name="By0" size="1">
<option value="全部">全部</option>
<option value="及格">及格</option>
<option value="不及格">不及格</option>
</select>
<%
Dim strSearchSql ,strKc ,strBy ,strBj ,strBy0,strxq
strBy = Request.form("By")
strBy0 = Request.form("By0")
strBj = trim(Request.form("classid"))
strKc = Request.form("Kc")
strxq = Request.form("xq")
If strBj <> "" And strBy <> "" and strKc <> "" and strby0 <> "" Then
If strBy = "zp" and strby0 = "全部" Then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"'"
elseIf strBy = "zp" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen > 59"
elseIf strBy = "zp" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and zongpingfen < 60"
elseIf strBy = "bukao1" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 > 59"
elseIf strBy = "bukao1" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao1 < 60"
elseIf strBy = "bukao2" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 > 59"
elseIf strBy = "bukao2" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao2 < 60"
elseIf strBy = "bukao3" and strby0 = "及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 > 59"
elseIf strBy = "bukao3" and strby0 = "不及格" then
strSearchSql = "WHERE class = '"& strBj &"' and xueqi = '"& strxq &"' and kemu = '"& strKc &"' and bukao3 < 60"
Else
strSearchSql = "WHERE "& strBy &" = '"& strBj &"' and kemu = '"& strKc &"'"
End If
Else
strSearchSql = "WHERE class = '"& bj &"'"
End If
Dim rs,rs11,rs22 ,strSql ,Num ,pageNum ,page ,loopNum
strSql = "SELECT * FROM Student_cj " & strSearchSql
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql,conn,3,3
'if request("search")="搜索" or isempty(session("str")) then
'session("str")=strSql
'end if
'rs.open session("str"),conn,1,1
%>
<%
If rs.recordcount > 0 Then
rs.pagesize = 14
Num = rs.recordcount
pageNum = rs.pagecount
page = Request.QueryString("page")
If page <> "" Then
page = Cint(page)
ElseIf page < 1 Then
page = 1
Else
page =1
End If
If page < 1 then
page =1
End If
If page*rs.pagesize >Num and Not ((page-1)*rs.pagesize <Num) Then
page = 1
End If
rs.absolutepage = page
If page <> pageNum Then
LoopNum = rs.pagesize
Else
LoopNum = Num - (page-1)*rs.pagesize
End If
%><input type="submit" name="search" value="搜索"/>
</td>
</form></table></table>
</td>
<% For i = 1 to LoopNum %>
记录显示部分
<% rs.movenext
Next %>
<tr>
<td colspan="16" bgcolor="#B3CBFF" width="0" height="23"><div align="center">
总共找到<%=Num%>条记录 <a href="index_student_kq.asp?page=1"><font color="#0000FF">首页</font></a><font color="#0000FF"> </font><a href="index_student_kq.asp?page=<%=page-1%>"><font color="#0000FF">上一页</font></a><font color="#0000FF"> </font[color=FF0000]><a href="index_student_kq.asp?page=<%=page+1%>&xueqi=<%=strxq%>&kemu=<%=strkc%>"><[/color]font color="#0000FF">下一页</font></a><font color="#0000FF"> </font><a href="index_student_kq.asp?page=<%=pageNum%>"><font color="#0000FF">尾页</font></a> 页次:<%=page%>/<%=pagenum%> 共<%=pageNum%>页</div></td>
</tr>
<tr>
<td colspan="16" bgcolor="#C2A6FF" width="0" height="20">
<p align="center">
<input type="submit" name="Submit" value=" 进入添加所选中学生的考勤次数 " style="border: 1pt solid #EEEEEE">
<input type="reset" name="Submit2" value=" 重新选择 " style="border: 1pt solid #EEEEEE"></td>
</tr>
</table>
<%
Else
%>
<p align="center">没有相关记录!</td>
<%
End If
%>