ASP實現對新聞的分頁例子

來源:互聯網
上載者:User
分頁 實現對新聞的分頁例子,原始碼如下:
<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>   </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 & " </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> "
  Response.Write "<font color:#ccffcc">總共有:" & Rs.PageCount & " 頁</font>" & vbCrlf
  Response.Write "<INPUT type=button value=關閉視窗 name=button1 height=12 size=18   
   style="BACKGROUND-COLOR: beige; FONT-SIZE: smaller;
  HEIGHT: 22px; WIDTH: 66px"></td>" & vbCrlf
  Response.Write "</tr>" & vbCrlf
end if
%>
</table>

相關文章

聯繫我們

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