一个分页的例子

<table>
<%
strCode = Request.QueryString("itemcode")
Set Conn = Server.CreateObject("Adodb.Connection")
Conn.Open Application("tt18_ConnectionString")
Set Rs = Server.CreateObject("Adodb.Recordset")
Sql="select * from NewsHeadC where itemcode = ""&strCode&"" order by TrDate DESC,a.NewsTime DESC"
Rs.Open Sql,Conn,1,3
Rs.PageSize = 15
Count = Rs.PageCount
if Rs.BOF or Rs.EOF then
  Response.Write "<tr>" & vbCrlf
  Response.Write "<td width=120 align=left bgcolor=#538E7B>&nbsp;&nbsp;&nbsp;</td>" & vbCrlf
  Response.Write "<td width=80% bgcolor=#95D2FF>對不起,還沒有----相應的數據</span>" & vbCrlf
  Response.Write "</td></tr>" & vbCrlf
else
  Rs.AbsolutePage = page
  for i = 1 to Rs.PageSize
    Trdate = left(RS("trdate"),4) & "-" & mid(RS("trdate"),5,2) & "-" & right(RS("trdate"),2)
    Response.Write "<tr>" & vbCrlf
    Response.Write "<td width=120 align=left bgcolor=#C0DAD1>" & Trdate & "&nbsp;</td>" & vbCrlf
    Response.Write "<td width=80% bgcolor=#e4e4e4 height=20>" & vbCrlf
    Response.Write "<a href=""javascript:goto_jump(" & Rs("id") & "," & Rs("trdate") & ","" &    
       Rs("Newscode") & ""," & Rs("Identity") & ")""> " & vbCrlf
    Response.Write Rs("HeadLine") & "</a></td>" & vbCrlf
    Response.Write "</tr>" & vbCrlf
    Rs.MoveNext
    If Rs.EOF Then Exit For
  next
  Response.Write "<tr>" & vbCrlf
  Response.Write "<td align=right colspan=3 bgcolor=#99cccc>" & vbCrlf
  if page <>1 then
     Response.Write "<a href=relnews.asp?page=1&itemcode="&strCode&">首頁</a>" & vbCrlf
  end if
  tmppage = page - 1
  if tmppage <= 0 then
     tmppage = 1
  else
     Response.Write"<a href=relnews.asp?page="&tmppage&"&itemcode="&strCode&">上一頁</a>"& vbCrlf
  end if
  tmppage = page + 1
  if tmppage > Rs.PageCount then
     tmppage = page
  else
     Response.Write "<a href=relnews.asp?page="&tmppage&"&itemcode="&strCode&">下一頁</a>"&vbCrlf
  end if
  if Cstr(page) <> Cstr(Rs.PageCount) then
    Response.Write "<a href=relnews.asp?page="&Rs.PageCount&"&itemcode="&strCode&">尾頁</a>&vbCrlf
  end if
  Response.Write "<font color:#ccffcc">第" & page & "頁</font>&nbsp;"
  Response.Write "<font color:#ccffcc">總共有:" & Rs.PageCount & " 頁</font>" & vbCrlf
  Response.Write "<INPUT type=button value=關閉窗口 name=button1 height=12 size=18  
  οnclick="javascript:return window.close();" style="BACKGROUND-COLOR: beige; FONT-SIZE: smaller;
  HEIGHT: 22px; WIDTH: 66px"></td>" & vbCrlf
  Response.Write "</tr>" & vbCrlf
end if
%>
</table> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值