<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!-- #include file="conn.asp" --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>分页显示</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <table align=center border=1><tr bgcolor=#00FF00 > <% sql="select * from SbaseInfo" rs.Open sql, conn, 1 page=1 ' 设置变量page=1 rs.PageSize = 3 '每页显示3个记录 if Not IsEmpty(Request("Page")) then '如果请求相应页数据 Page = CInt(Request("Page")) '将请求的页数赋给page if Page > rs.PageCount then rs.AbsolutePage = rs.PageCount elseif Page <= 0 then Page = 1 else rs.AbsolutePage = Page end if End if Page = rs.AbsolutePage %> <% For j = 0 to rs.Fields.Count -1 '输出个字段名称 filde = "<td nowrap>" & rs.Fields(j).name & "</td>" 'nowrap属性避免表格自动换行 Response.Write(filde) Next %> <% For i = 1 to rs.PageSize '循环3次显示数据 if rs.EOF then Exit For end if '利用for next 循环依次读出记录 %> <% j = 0 Response.Write("<tr>") For j = 0 to rs.Fields.Count -1 '输出个字段数据 filde = "<td nowrap>" & rs.Fields(j) & "</td>" Response.Write(filde) Next %> <% rs.MoveNext next %> </table> </form> <p align="center"> <%if request("page")>1 then%> <a Href="分页显示.asp?Page=<% = 1%>">首页</a> <a Href="分页显示.asp?Page=<% =page -1 %>">上一页</a> <%end if %> <% If page +1 > rs.pagecount Then page = rs.pagecount -1 '如果点击"下一页"后page值大于总页数,则在当前页将下一页的值赋为总页数 %> <%if request("page")<>rs.pagecount then %> <a Href="分页显示.asp?Page=<% = page + 1%>">下一页</a> <a Href="分页显示.asp?Page=<% = rs.PageCount%>">尾页</a> <% end if %> <% rs.close Set rs = Nothing conn.close set conn=nothing %> </body> </html> 把数据库和链接改一下就可直接用!