欢迎光临
我们一直在努力

一个分页的例子-ASP教程,ASP应用

建站超值云服务器,限时71元/月

实现对新闻的分页例子,源代码如下:
<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   
  onclick=”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)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 一个分页的例子-ASP教程,ASP应用
分享到: 更多 (0)