1.查询输出数据库内容,设置每页显示信息条数 <% Sql = "Select * From User where Name='黑夜' Order by ID desc" Set Rs = Server.CreateObject("Adodb.recordset") Rs.Open Sql,conn,1,1 '分页显示 Page = Clng(Request.QueryString("page")) Rs.PageSize = 10 If Page < 1 Then Page = 1 If Page > Rs.PageCount Then Page = Rs.PageCount Rs.AbsolutePage = Page %>
2.在显示内容框架顶部,添加循环语句 <% For i = 1 to Rs.PageSize %>
3.在显示内容框架底部,添加循环结束语句 <% Rs.MoveNext If Rs.EOF Then Exit For Next %>
4.在底部适合位置,添加分页按钮代码 <center>共<%=Rs.RecordCount%>条信息 分<%=Rs.pagecount%>显示 当前是第<%=page%>页 <% If Page > 1 Then Response.Write "<a href=?page=1 class=dh><span style='font-size: 9pt' id=fps0>首页</span></a> " Response.Write "<a href=?page=" & Page-1 & " class=dh><span style='font-size: 9pt' id=fps0>上一页</span></a> " End If If Page < Rs.PageCount Then Response.Write "<a href=?page=" & Page+1 & " class=dh><span style='font-size: 9pt' id=fps0>下一页</span></a> " Response.Write "<a href=?page=" & Rs.PageCount & " class=dh><span style='font-size: 9pt' id=fps0>尾页</span></a> " End If %> 到第 <select size=1 name=select onchange="location.href=this.options[this.selectedIndex].value"> <% For i = 1 To Rs.PageCount %> <option <% If Page = i Then Response.Write "selected" %> value=?page=<%=i%>><%=i%></option> <% Next %> <select>页 <% Rs.close set Rs = nothing %> |