<% sql = "select……………………省略了sql语句 Set rs=Server.Createobject("ADODB.RECORDSET") rs.Open sql, conn, 1, 1 if not rs.eof then pages = 30 ’定义每页显示的记录数 rs.pageSize = pages ’定义每页显示的记录数 allPages = rs.pageCount’计算一共能分多少页 page = Request.QueryString("page")’通过浏览器传递的页数 ’if语句属于基本的排错处理 if isEmpty(page) or Cint(page) < 1 then page = 1 elseif Cint(page) > allPages then page = allPages end if rs.AbsolutePage = page Do while not rs.eof and pages > 0 %> 这里输出你要的内容……………… <% pages = pages - 1 rs.MoveNext Loop else Response.Write("数据库暂无内容!") End if rs.Close Set rs = Nothing %> |
<% SUB pageUrl(pUrl) Dim eUrl txts = Request.ServerVariables("URL") txts = left(txts,instrrev(txts,"/",len(txts))-1) eUrl = "http://"; & Request.ServerVariables("server_name") & txts For i =1 to allpages txt = "" txt = "<strong>" txt = txt & "<a href=" & eUrl & pUrl & "page="&i & ">" if i = Cint(Page) then txt = txt & "<font color=’bb0000’>" txt = txt & (i) if i = Cint(Page) then txt = txt & "</font>" txt = txt & "</a> ∥ </strong>" Response.Write(txt) Next END sub %> |