一聚教程网:一个值得你收藏的教程网站

热门教程

asp分页程序

时间:2022-07-02 22:36:21 编辑:袖梨 来源:一聚教程网

<%@language="vbscript" codepage="936"%>
<%
'定义数据连接
option explicit
on error resume next
dim startime,endtime
startime=timer()
dim db,conn,rs
db = "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("./db.mdb")
set conn = server.createobject("adodb.connection")
set rs = server.createobject("adodb.recordset")
conn.open db
%>
<%
'**************
'分页导航栏函数
'输出wzpage值
'**************
Function pagination(pagecount)
   Dim wzpage,wzpagecount,pagenum,boardid
   boardid = Request.QueryString("board_id")
   If boardid = 0 Then boardid = 1
       If Len(Request.QueryString("page"))<>0 Then
          wzpage = clng(Request.QueryString("page"))
         Else
          wzpage =1
       End If
       If wzpage <= 0 Then wzpage =1
       pagenum = (wzpage 10)*10+1
       If wzpage mod 10 = 0 Then pagenum = (wzpage 10)*10-9
       If wzpage > 10 Then
         Response.Write ("")
            Response.Write ("9")
   Response.Write ("7")
            Response.Write ("
")
    End If
       For pagenum = pagenum To pagenum + 9
           If pagenum = wzpage Then
                  Response.Write ("")
                  Response.Write (" ["& pagenum &"] ")
                  Response.Write ("
")
        Else
                  Response.Write (" ")
                  Response.Write ("["& pagenum &"]")
                  Response.Write ("
")
   End If
         If pagenum >= pagecount Then Exit For
       Next
     If wzpage < (pagecount - (pagecount 10))  Then
         Response.Write ("")
            Response.Write ("8")
   Response.Write (":")
            Response.Write ("
")
   End If
End Function
%>
<%
dim rssql,getstring
getstring = clng(request.querystring("board_id"))
if getstring = 0 then getstring = 1

'******************************************
'取文章总数及每页重复显示条数,准备分页
'wzcount 文章总数
'wzrep 重复显示条数
'wzpage 分页参数id
'wzpagecount 总页数
'******************************************
dim wzcount,wzrep,wzpage,wzpagecount,wzpagerep,boardstr
wzrep = 30
'rssql = "select count(id) from `table1`"
'rs.open rssql,conn,0,1,&h0001
wzcount = conn.execute ("select count(id) from `table1`",0,1)(0)
'rs.close
wzpagecount = abs(int(-abs(wzcount/wzrep)))
wzpage = clng(request.querystring("page"))
if len(wzpage) = 0 or wzpage = 0 then wzpage = 1

%>


分页测试

css" type="text/css">



 
   
   
   
   
 
  <%
'取文章列表
rssql = "select id,aaaa,bbbb,cccc from `table1` order by id desc"
rs.open rssql,conn,1,1,&h0001
'根据分页参数获取当前页面纪录
rs.absoluteposition=rs.absoluteposition+((abs(wzpage)-1)*wzrep)
'显示文章标题列表
if rs.eof or rs.bof then%>

       
 
<% else
dim i,bgcolor
for i = 0 to wzrep-1
 if rs.eof then exit for
'while not rs.eof and i <= wzrep
 bgColor="#FFFFFF"
 if i mod 2=0 then bgColor="#DFEFFF"
%>
 
   
   
   
   
 
<%
rs.movenext
'i=i+1
'wend
next
end if
%>
ID标题内容(显示前20个字)时间
暂无记录
<%=rs(0)%><%=rs(1)%><%=left(rs(2),20)%><%=rs(3)%>


 
   
 
 
<%= wzcount%><%= wzrep%>/页 共<%= wzpagecount%> <%= pagination(wzpagecount)%>

 

 
   
 

      <%endtime=timer()%>
      本页面执行时间:<%=formatnumber((endtime-startime)*1000,3)%>毫秒



<%
'释放资源
rs.close
set rs = nothing
conn.close
set conn = nothing
%>

热门栏目