ajax實現分頁效果二

來源:互聯網
上載者:User

<!--#include file="conn.asp"-->// 調用資料庫了,

<%
'Dim pagesize
'sql="select top 1 * from [pagesize] order by id desc"
'rs.open sql,conn,1,1
'pagesize=rs("pagesize")
'rs.Close
If session("pagesize")="" Then session("pagesize")=9
Dim page
page=unescape(Request.QueryString("page"))
If page<>"" Then
 sql="select * from [test] order by id asc"
 rs.open sql,conn,1,1
 If rs.eof Then
  Response.Write(escape("還沒有任何資料"))
 Else
  rs.pagesize=session("pagesize")
  page=CLng(page)
  If page<1 Then
   page=1
  ElseIf page>rs.pagecount Then
   page=rs.pagecount
  End If
  rs.absolutepage=page
  Dim i,str
  str=str & "<div style='margin:0'>"
  For i=1 To rs.pagesize
   str=str & rs("id") & ". <a href='" & rs("weburl") & "' title='前往該網站' target='_blank'>" & rs("webname") & "</a><br />"
   rs.movenext
   If rs.eof Then Exit For
  Next
  str=str & "</div><div style='margin-top:10px;line-height:30px;text-align:left;border-top:1px #999 solid'>"
  str=str & "<a href='javascript:void(getweblist(1))'><<</a> "
  For i=1 To rs.pagecount
   If i=page Then
    str=str & "<span style='font-weight:bold;color:red;font-size:16px;'>" & i & "</span> "
   Else
    str=str & "<a href=javascript:void(getweblist(" & i & "))>" & i & "</a> "
   End If
  Next
  str=str & " <a href='javascript:void(getweblist(" & rs.pagecount & "))'>>></a>"
  str=str & "</div>"
  str=escape(str)
  Response.Write(str)
 End If 
 rs.Close
 Set rs=Nothing
 conn.Close
 Set conn=Nothing
Else
 Response.Write(escape("Error:頁數不可為空!"))
End If
%>
  

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.