ASP查询分页问题
我想做一个查询分页,现在好像有问题。现在的代码实现了一进页面就可以分页显示所有的记录。但是如果我输入查询条件之后,能够得到分页显示,但是只有第一页是符合条件了,后面的页的记录都是之前的那些记录。请大家帮帮忙。还有,我想把我的功能改成一进页面显示部分为空,不用显示所有的记录,当输入查询条件之后再分页显示,我现在的代码如下,请大家帮忙看看,谢谢啦!
[code=ASP][/code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- #include file="conn.asp" -->
<!--#include file="Function.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DCC Database System</title>
</head>
<%
docid=request("id")
if docid<>"" then
conn.execute "delete from doclist where ID="& docid
end if
%>
<%
getdocno=Trim(Request("getdocno"))
getrev=Trim(Request("getrev"))
getproject=Trim(Request("getproject"))
page=clng(request("page"))
if page<1 then page=1
if page>rs.recordcount then page=rs.recordcount
Set rs=CreateObject("ADODB.RecordSet")
sql="Select * from doclist where Doc_no like '%"& getdocno &"%' and Project like '%"& getproject &"%' "
rs.Open sql,conn,1,1
rs.movefirst
If Not rs.EOF Then
rs.Pagesize=20
rs.Absolutepage=Page
End If
%>
<body>
<form id="myform" name="myform" method="post" action="">
<table width="970" border="0" cellspacing="0" cellpadding="0" align="center" height="269" >
<tr>
<td height="260" valign="bottom" bordercolor="#9966CC" background="images/top.jpg">
<table width="700" border="0" align="right" cellpadding="0" cellspacing="0" height="19">
<tr>
<td width="109" height="19" align="center" valign="middle"><b><a href="newdoc.asp">
New DOC</a></b></td>
<td width="101" height="19" align="center" valign="middle"><b>
<a href="editdoc.asp">Edit DOC</a></b></td>
<td width="123" height="19" align="center" valign="middle">search</td>
<td width="104" height="19" align="center" valign="middle">history</td>
<td width="146" height="19" align="center" valign="middle">chang
password</td>
<td width="107" height="19"> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="9" align="center" valign="top" background="images/line.jpg">
<table border="0" width="96%" id="table1" height="176">
<tr>
<td height="67">
<table border="0" width="100%" id="table2" height="75">
<tr>
<td height="37" align="left">
<img border="0" src="images/ico02.gif" width="32" height="32"> <font size="4" color="#9999FF">
<b>Edit Document</b></td>
</tr>
<tr>
<td bgcolor="#E7F0FA" align="left" > <b>
<font color="#FF0000">Doc_no:</font></b><font size="3"><input type="text" name="getdocno" value="<%=request("getdocno")%>" size="27" ></font><b>
<font color="#FF0000">Project:</font></b><font size="3">
<select size="1" name="getproject">
<option>N/A</option>
<%
Dim rsPro,ProName,selProName
Set rsPro=Server.CreateObject("ADODB.RecordSet")
selProName=Request("getproject")
rsPro.Open "select * from project_info order by project asc",conn,1,1
ProName=""
rsPro.movefirst
IF rsPro.EOF Then
Response.Write "<option>No record in the database!</option>"
Else
Do while not rsPro.EOF
IF trim(rsPro("project"))<>ProName Then
IF selProName=trim(rsPro("project")) Then
Response.Write "<option selected "
Response.Write "value='"&rsPro("project")&"' >"
Response.Write rsPro("project")&"</option>"
Else
Response.Write "<option value='"&rsPro("project")&"' >"
Response.Write rsPro("project")&"</option>"
End IF
ProName=rsPro("project")
End IF
rsPro.MoveNext
Loop
End IF
'关闭用过的ADODB.RecordSet
rsPro.Close
Set rsPro=Nothing
%>
</select></font><b>
</b><font size="3">
<input type="submit" value="Search" name="search"></font></td>
</tr>
</table>
<table border="0" width="100%" id="table3">
<tr>
<td align="right">
<%PageBreak Page,"editdoc.asp?docno="&getdocno&"&rev="&getrev&"&project="&getproject&"&",rs%>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" width="100%" id="table4" height="66" style="border-style: solid; border-width: 2px" bordercolor="#000000">
<tr bgcolor="#9AA7ED" >
<td width="132" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Doc No</font></b></td>
<td width="24" height="18%"><b>
<font color="#FFFFFF" size="2">Rev</font></b></td>
<td width="56" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Project</font></b></td>
<td width="74" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Model</font></b></td>
<td width="175" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Description</font></b></td>
<td width="115" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Effective Date</font></b></td>
<td width="113" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Obsolete Date</font></b></td>
<td width="24" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">DMR</font></b></td>
<td width="62" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Modify</font></b></td>
<td width="59" height="18%" align="center"><b>
<font color="#FFFFFF" size="2">Save as</font></b></td>
<td height="18%" align="center"><b>
<font color="#FFFFFF" size="2">
Delete</font></b></td>
</tr>
<% for i=1 to rs.pagesize
%>
<tr bgcolor="#ececec" align="center" onMouseOver="this.bgColor='#B0E2FF'" onMouseOut="this.bgColor='#ececec'">
<td width="132"><font size="2"><%=rs("Doc_no")%> </font></td>
<td width="24"><font size="2"><%=rs("Rev")%> </font></td>
<td width="56"><font size="2"><%=rs("Project")%> </font></td>
<td width="74"><font size="2"><%=rs("Model")%> </font></td>
<td width="175"><font size="2"><%=rs("Description")%> </font></td>
<td width="115"><font size="2"><%=rs("Effective_Date")%> </font></td>
<td width="113"><font size="2"><%=rs("Obsolete_Date")%> </font></td>
<td width="24"><font size="2"><%=rs("DMR")%> </font></td>
<td width="62"><font size="2"><a href="updoc.asp?ID=<%=rs("ID")%>">Modify</a></font></td>
<td width="59" ><font size="2">Save as</font></td>
<td ><font size="2" onclick="return del()"><input type=hidden name=id value="<%=request("id")%>"><a href="editdoc.asp?ID=<%=rs("ID")%>">Delete</a></font></td>
</tr>
<%rs.MoveNext
if rs.eof then exit for
next%>
</table>
</td>
</tr>
</table>
</tr>
<tr>
<td height="51"><img src="images/copyright.jpg" width="990" height="51" ></td>
</tr>
</table>
</form>
</body>
</html>