asp 漂亮通用數字分頁代碼

來源:互聯網
上載者:User

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>數字型分頁</title><style type="text/css"><!--dl dd a { font-size:13px; color:#004600; text-decoration:none;}dl dd span { padding:10px; color:#FF0000; font-size:12px; font-weight:bold;}ul { list-style-type:none; overflow:hidden;}ul li { float:left; border:0; margin:0; padding:0; }ul li a { display:block; width:25px; height:20px; border:solid 1px #9aafe5;margin-right:2px; text-decoration:none; font-size:12px; line-height:20px; text-align:center; font-weight:500;font-weight:bold;color:#006799;}ul #AbsPage a { background:#006799; color:#FFFFFF;}ul #NextPage a { width:45px; height:20px; font-size:12px; color:#006799;}ul #PreviousPage a { width:65px; height:20px; font-size:12px;color:#006799;} --></style></head><body><%dim conn,connstr,rs,sqldatabase = "DataBase/test.mdb"Set conn = Server.CreateObject("ADODB.Connection")connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(database)conn.open connstrSet rs = Server.Createobject("ADODB.Recordset")sql="select id,title from news"rs.open sql,conn,1,1If rs.eof ThenElse    rs.pagesize=3    page=request.querystring("page")    If Not Isnumeric(page) or page="" Then      page=1    else      page=cint(page)    End if    if page<1 then page=1    if page>rs.pagecount then page=rs.pagecount    rs.AbsolutePage = page    for i=1 to rs.pagesize        title = rs("title")   %>   <dl>    <dd><span><%=rs("id")%></span><a href="#"><%=rs("title")%></a> </dd>  </dl>  <%    rs.movenext    if rs.eof then      Exit For    End if    nextend if%>  <ul>     <%    if page>3 then StartPage=page-3 else StartPage=1if page<rs.pagecount-3 then EndPage=page+3 else EndPage=rs.pagecountif StartPage>=3 then response.write "<li id='PreviousPage'><a href=page.asp?page="&page-1&">Previous</a><span></span></li>"for j=StartPage to EndPage    if j=page then     response.write "<li id='AbsPage'><a href=page.asp?page="&j&">"&j&"</a></li>"   else     response.write "<li><a href=page.asp?page="&j&">"&j&"</a></li>"   end ifnextif EndPage<rs.pagecount then response.write "<li id='NextPage'><a href=page.asp?page="&page+1&">Next</a><span></span></li>"rs.close %> </ul></body></html><%set rs=nothing%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.