|
以下是很基础的分页代码
lz只要获取一下参数并适当的改一下SQL语句
还有在上一页 ,下一页的链接上传递一下你的搜索关键字就好了
=========================Page.asp(RS分页代码)==================================================
<body>
<%
Dim rs,sql,i,paper,pages
Set rs = Server.CreateObject("ADODB.RECORDSET")
sql = "select * from userinfo order by id asc"
rs.Open sql,conn,1,1
%>
<table width="450" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="85" align="center">id</td>
<td width="161" align="center">username</td>
<td width="204" align="center">password</td>
</tr>
<%
If rs.Eof Then
Response.Write("<tr><td colspan='3' align='center'>暂时没有记录!</td></tr>")
Else
rs.PageSize=10
paper = rs.PageCount
pages = Trim(Request.QueryString("page"))
If pages = "" Then pages = 1
If Not IsNumeric(pages) or Instr(pages,"-")<>0 or Instr(pages,".")<>0 Then
Response.Write("<script>alert('非法操作!');history.back()</script>")
Response.End()
End If
pages = Int(pages)
If pages < 1 Then pages = 1
If pages > paper Then pages = paper
rs.Absolutepage = pages
For i = 1 To rs.PageSize
%>
<tr>
<td align="center"><%=rs("id")%></td>
<td align="center"><%=rs("username")%></td>
<td align="center"><%=rs("password")%></td>
</tr>
<%
rs.movenext
If rs.eof Then Exit For
Next
%>
<tr>
<td colspan="3" align="left">
共有<font color="red"><%=rs.RecordCount%></font>条记录,
共有<font color="red"><%=paper%></font>页,
当前第<font color="red"><%=pages%></font>页,
<a href="?page=1">首页</a>
<a href="?page=<%=pages-1%>">上一页</a>
<a href="?page=<%=pages+1%>">下一页</a>
<a href="?page=<%=paper%>">尾页</a>
</td>
</tr>
<%
Rs.Close
Set Rs = Nothing
End If
%>
</table>
</body> |
|