asp最常用的分页函数

复制代码 代码如下:

    rs.open sql,conn,1,1
    if rs.eof and rs.bof then
     response.write "还没找到文章

"
  else
   totalPut=rs.recordcount
   maxperpage=18
   if currentpage<1 then
    currentpage=1
    end if
   if (currentpage-1)*maxperpage>totalput then
      if (totalput mod maxperpage)=0 then
      currentpage=totalput\maxperpage
      else
      currentpage=totalput\maxperpage+1
      end if
   end if
    if currentpage=1 then
    showpage1 totalput,maxperpage,"infotype.asp?id="&request("id")
    showcontent()
    showpage totalput,maxperpage,"infotype.asp?id="&request("id")
    else
       if (currentpage-1)*maxperpage       rs.move (currentpage-1)*maxperpage
       dim bookmark
       bookmark=rs.bookmark
       showpage1 totalput,maxperpage,"infotype.asp?id="&request("id")
       showcontent
       showpage totalput,maxperpage,"infotype.asp?id="&request("id")
       else
       currentpage=1
       showpage1 totalput,maxperpage,"infotype.asp?id="&request("id")
       showcontent
       showpage totalput,maxperpage,"infotype.asp?id="&request("id")
       end if
    end if 
end if
%>
<%
  sub showcontent()
  %>
  
    ID

    选择

    信息标题

    更新日期

    点击

    添加人

    编辑

    删除

    生成[归零]

    
  <%

  i=1
   do while not rs.eof
%>

  
    <%=rs("id")%>
    
           ">
     
    " target="_blank">[<%=rs("type_id")%>]<%thetitle1=rs("title")
    strcounts=truelen(thetitle1)
    response.write thetitle1
    %>
    <%
    datetime=rs("datetime")
    yname=year(datetime)
mname=month(datetime)
if len(mname)<2 then mname="0"&mname
dname=month(datetime)
if len(dname)<2 then dname="0"&dname
foldername=yname&mname
    %>
    <%=foldername%>/<%=rs("id")%>.htm" title="查看生成的静态页面" target="_blank"><%=rs("datetime")%>
    <%=rs("hits")%>
    <%=rs("author")%>
    ">修改
    )">删除
    )">生成(','','width=0,height=0')"><%=rs("shengcheng")%>)
  
  <%
  i=i+1
   if i>maxperpage then exit do
  rs.movenext  
  loop
  %>
  
    ID
    选择
    信息标题
    更新日期
    点击
    添加人
    编辑
    删除
    生成
  
  <%
  end sub    
  %>

  
    
    
    <%
    function showpage(totalnumber,maxperpage,filename)
    %>
  
    
    <%
dim n
if totalnumber mod maxperpage=0 then
n=totalnumber\maxperpage
else
n=totalnumber\maxperpage+1
end if
%>
共有<%=totalnumber%>/<%=maxperpage%>条,

当前页<%=currentpage%>/<%=n%> 
        <%if currentpage<2 then%>
        [首页] [上一页]
        <%else%>
        ">[首页] &page=<%=currentpage-1%>">[上一页]
        <%end if%><% if n-currentpage<1 then%>
        [下一页] [尾页]<%else%>&page=<%=currentpage+1%>">[下一页] &page=<%=n%>">[尾页]
        <%end if%>
        转到:
onChange="location.href=this.options[this.selectedIndex].value">
     <%for j=1 to n
     if currentpage=j then
     %>&page=<%=j%>" selected><%=j%>
     <%
     else
     %>
     &page=<%=j%>"><%=j%>
     <%
     end if
     next
     %>
    
        
    
    <%
    end function
    %>
    <%
    function showpage1(totalnumber,maxperpage,filename)
    %>
  
    
    <%
dim b
if totalnumber mod maxperpage=0 then
b=totalnumber\maxperpage
else
b=totalnumber\maxperpage+1
end if
%>
共有<%=totalnumber%>/<%=maxperpage%>条,

当前页<%=currentpage%>/<%=b%> 
     <%
     dxystart=currentpage-5
     if dxystart<1 then dxystart=1
     dxyend=currentpage+5
     if dxyend>b then dxyend=b
     for dxy=dxystart to dxyend
     if dxy=currentpage then
     response.write "["&""&dxy&""&"]"&" "
     else
     response.write "["&dxy&""&"]"&" "
     end if
     next
     %> 
        
    
    <%
    end function
    %>
  

<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

你可能感兴趣的:(asp最常用的分页函数)