搜索后分页显示
<!--#include file="check.asp" -->
<!--#include file="conn.asp" -->
<script language="javascript">
function checkname()
{
if(document.form1.studentname.value=="")
{
alert("名字不能为空")
document.form1.studentname.focus()
}
form1.submit()
}
</script>
<script language="vbscript">
sub checkpage()
c=document.form2.page.value
if c<>"" then
if IsNumeric(c) then
form2.submit()
else
msgbox "页数不是整数!"
exit sub
end if
else
msgbox "不能为空!"
exit sub
end if
end sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table border="1">
<form name="form1" method="get" action="student_admin.asp?studentname=<%=request("studentname")%>">
<tr ><td colspan="5">以下为姓名为:<%=request("studentname")%>的考生<input type="text" name="studentname" value="<%=request("studentname")%>"><input type="button" onClick="checkname();" value="search" ></td></tr>
<tr>
<td width=170>考试号</td>
<td width=170>考试分数</td>
<td width=170>补考设置</td>
<td width=170>补考成绩</td>
<td width=170>修改资料</td>
</tr>
</form>
<%
if trim(request("page"))="" then
page=1
else
page=cint(trim(request("page")))
end if
studentname=trim(request("studentname"))
set rs=server.CreateObject("adodb.recordset")
sqlfind="select * from student where studentname='"&request("studentname")&"'"
rs.open sqlfind,conn,1,1
if (rs.bof and rs.eof) then
%>
<tr><td colspan="5" align="center">查无此学生!</td></tr>
<%
else
studentnumber=rs("studentnumber")
set rss=server.CreateObject("adodb.recordset")
sqlfind="select * from examination where studentnumber='"&studentnumber&"'"
rss.open sqlfind,conn,1,1
rss.pagesize=3
if (rss.bof and rss.eof) then
%>
<tr><td colspan="5" align="center">该学生还没考试</td></tr>
<%
else
' 调试 response.Write "kaole!"
if page<1 then
page=1
end if
if page>rss.pagecount then
page=rss.pagecount
end if
rss.absolutepage=page
'调试
'response.Write "page"&page&" "
'response.Write "pagecount"&rss.pagecount
'response.Write"studentname"&rs("studentname")
for i=1 to rss.pagesize
%>
<tr>
<td width=170><%=rss("examinationid")%></td>
<td width=170><%=rss("score")%></td>
<td width=170><%if rss("pass")=true then response.Write "通过" else response.Write "不及格" end if%></td>
<td width=170><%=rss("makeup")%></td>
<td width=170><a href='student_admin_edit.asp?studentnumber=<%=studentnumber%>'>修改数据</a></td>
</tr>
<%
if rss.eof then
exit for
end if
rss.movenext
next
rs.close
rss.close
end if
end if
%>
<form name="form2" method="get" action="student_admin.asp?studentname=<%=studentname%>">
<tr align="right"><td colspan="5"><input type="text" name="page" ><input type="button" onClick="checkpage();" value="goto"><input type="hidden" name="studentname" value="<%=studentname%>">
</td></tr>
</form>
<%
set rs=server.CreateObject("adodb.recordset")
sqlfind="select * from student where studentname='"&studentname&"'"
rs.open sqlfind,conn,1,1
if not (rs.bof and rs.eof) then
studentnumber=rs("studentnumber")
set rss=server.CreateObject("adodb.recordset")
sqlfind="select * from examination where studentnumber='"&studentnumber&"'"
rss.open sqlfind,conn,1,1
if not (rss.bof and rss.eof) then
rss.pagesize=3
'调试
'response.Write studentnumber
'response.Write "page"&page&" "
'response.Write "pagecount"&rss.pagecount
'response.Write"studentname"&rs("studentname")
%>
<tr><td colspan="5">
<%
if page<>1 then
%>
<a href='?studentname=<%=studentname%>&page=1'>第一页</a>
<a href='?studentname=<%=studentname%>&page=<%=page-1%>'>上一页</a>
<%
end if'括号不能加 <%=(page-1)% >
%>
<%
if page<>rss.pagecount then
'response.Write "!!"
%>
<a href='?studentname=<%=studentname%>&page=<%=page+1%>'>下一页</a>
<a href='?studentname=<%=studentname%>&page=<%=rss.pagecount%>'>最后一页</a>
<%
end if
%>
</td>
</tr>
<%
end if
end if
%>
</table>
</body>
</html>