好用的ASP分页代码

<%
set rss=server.CreateObject("adodb.recordset")
sql="select * from Member"   '调入数据库表
rss.open sql,conn,1,1
if rss.recordcount<=0 then
response.Write"
无记录!
"
else
rss.PageSize =9 '每页记录条数
iCount=rss.RecordCount '记录总数
iPageSize=rss.PageSize
maxpage=rss.PageCount
page=request("page")

if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if

if page<1 then
page=1
elseif   page>maxpage then
page=maxpage
end if

rss.AbsolutePage=Page

if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
rss.absolutepage = page                
rowcount = rss.pagesize
x=rowcount/3      '每行显示产品数   pagesize/行数
%>



  
       <%for i=1 to x
     if not rss.eof   then
     %>

      
    
     <%loop%>
     <%end if
    rss.close
    conn.close
    set rss=nothing
    set conn=nothing
    %>
  

     <%do while not rss.eof and rowcount>0
     %>
    

          
            
          
          
            
          
        
<%if rss("Picture")<>"" then
response.Write ""
else
response.Write ""
end if
%>
            
<%= rss("Memname") %>

           <%
    rowcount=rowcount-1
    rss.movenext
    end if
    %>
           <%next%>
      




<%

call PageControl(iCount,maxpage,page,"border=0 align=center","

")

Sub PageControl(iCount,pagecount,page,table_style,font_style)
'生成上一页下一页链接
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("

" & vbCrLf )        
Response.Write("" & vbCrLf )
Response.Write("" & vbCrLf )                
Response.Write("" & vbCrLf )        
Response.Write("
" & vbCrLf )
Response.Write(font_style & vbCrLf )    

if page<=1 then
Response.Write ("首 页 " & vbCrLf)        
Response.Write ("上一页 " & vbCrLf)
else        
Response.Write("首 页 " & vbCrLf)
Response.Write("上一页 " & vbCrLf)
end if

if page>=pagecount then
Response.Write ("下一页 " & vbCrLf)
Response.Write ("尾 页 " & vbCrLf)            
else
Response.Write("下一页 " & vbCrLf)
Response.Write("尾 页 " & vbCrLf)            
end if

Response.Write(" 页次:" & page & "/" & pageCount & "页" &   vbCrLf)
Response.Write(" 共有 " & iCount & " 个记录 " &   vbCrLf)
Response.Write(" 转到" & "" & "页"   & vbCrLf & "")
Response.Write("
" & vbCrLf )        
End Sub%>



上一篇: asp通用分页类
下一篇: 简洁的js下拉菜单代码
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: 1614
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 300 字 | UBB代码 开启 | [img]标签 关闭