<!--#include file="conn.asp" --> <% Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select * from cnarticle order by cn_id desc" rs.Open sql,conn,1,1 %> <% page=request.querystring("page") 'page值为接受值 rs.PageSize = 2 '每页显示记录数 rs.AbsolutePage = Page '显示当前页等于接收的页数 %> <% For i = 1 to rs.PageSize '利用for next 循环依次读出当前页的记录 if rs.EOF then Exit For end if response.write("<br>文章内容是:"& rs("cn_content")) rs.MoveNext next%> <% rs.close Set rs = Nothing conn.close set conn=nothing %> |
<% For i = 1 to rs.PageSize if rs.EOF then Exit For end if response.write("<br>文章内容是:"& rs("cn_content")) rs.MoveNext next%> |
<!--#include file="conn.asp" --> <% Set rs = Server.CreateObject ("ADODB.Recordset") sql = "Select * from cnarticle" rs.Open sql,conn,1,1 %> <%filepath=request.servervariables("path_info")%> <% page=request.querystring("page") 'page值为接受值 rs.PageSize = 2 '每页显示记录数 if Not IsEmpty(page) then '如果page已经初始化... if Not IsNumeric(page) then '判断page值是否为数字 page=1 else Page = cint(page) '接收page并化为数字型赋给page变量 end if if Page > rs.PageCount then '如果接收的页数大于总页数 rs.AbsolutePage = rs.PageCount '设置当前显示页等于最后页 elseif Page <= 0 then '如果page小于等于0 rs.AbsolutePage = 1 '设置当前显示页等于第一页 else rs.AbsolutePage = Page '如果大于零,显示当前页等于接收的页数 end if else rs.AbsolutePage=1 end if Page = rs.AbsolutePage%> <% For i = 1 to rs.PageSize '利用for next 循环依次读出当前页的记录 if rs.EOF then Exit For end if response.write("文章标题是:"& rs("cn_title")) response.write("<br>文章作者是:"& rs("cn_author")) response.write("<br>文章加入时间是:"& rs("cn_time")) response.write("<br>文章内容是:"& rs("cn_content")) response.write("<hr>") rs.MoveNext Next %> <form action="<%=filepath%>" method="get"> <!--首先保证总页数不为1、不为0--> <%if rs.pagecount<>1 and rs.pagecount<>0 then%> <!--如果当前页数大于1,无论何时都应显示首页和上一页的连接--> <%if page>1 then%> [<a Href="<%=filepath%>?Page=<% = 1%>">首页</a>] [<a Href="<%=filepath%>?Page=<% = page -1 %>">上一页</a>] <!--如果当前页数大于1并且小于总页面数时,显示出尾页和下一页的连接--> <%if page<rs.pagecount then %> [<a Href="<%=filepath%>?Page=<% = page + 1%>">下一页</a>] [<a Href="<%=filepath%>?Page=<% = rs.PageCount%>">尾页</a>] <!--如果当前页数大于1并且仍大于或等于总页面数时,不显示出尾页和下一页的连接--> <%else%> [下一页] [尾页] <%end if%> <!--否则,当前页数不大于1,则只显示尾页和下一页的连接--> <%else%> [首页] [上一页] [<a Href="<%=filepath%>?Page=<% = page + 1%>">下一页</a>] [<a Href="<%=filepath%>?Page=<% = rs.PageCount%>">尾页</a>] <%end if %> <!--最终,总页数若为1、为0则没有任何连接--> <%else%> [首页] [上一页] [下一页] [尾页] <%end if%> [页次:<font color=red><b><%=page%></b></font>/<%=rs.PageCount%>] [共<%=rs.RecordCount%>篇 <font color=red><b><%=rs.PageSize%></b></font>篇/页] 转到<input name="page" size=5 value="<%=page%>">页 <input type="submit" value="Enter"> </form> <% rs.close Set rs = Nothing conn.close set conn=Nothing %> |
<% function pagination(pagecount,pagesize,page,resultcount) Dim query, a, x, temp action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME") query = Split(Request.ServerVariables("QUERY_STRING"), "&") For Each x In query a = Split(x, "=") If StrComp(a(0), "page", vbTextCompare) <> 0 Then temp = temp & a(0) & "=" & a(1) & "&" End If Next Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+this.page.value;return false;"">") if page<=1 then Response.Write ("[首页] [上一页] ") else Response.Write("[<a href=" & action & "?" & temp & "Page=1>首页</a>] ") Response.Write("[<a href=" & action & "?" & temp & "Page=" & (Page-1) & ">上一页</a>] ") end if if page>=pagecount then Response.Write ("[下一页] [尾页]") else Response.Write("[<a href=" & action & "?" & temp & "Page=" & (Page+1) & ">下一页</a>] ") Response.Write("[<a href=" & action & "?" & temp & "Page=" & pagecount & ">尾页</a>]") end if Response.Write("[页次:<font color=red>" & page & "</font>/" & pageCount) Response.Write("] [共" & resultcount & "条 <font color=red>"& pagesize & "</font>条/页]") Response.Write(" 转到" & "<input name=page size=4 value=" & page & ">" & "页<input type=submit value=go>") End function %> |
新闻热点
疑难解答