ASP实现对新闻的分页例子
类别: ASP教程
实现对新闻的分页例子,源代码如下:
<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
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>
<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
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>
- 上一篇: ASP实现随机提取数据库记录例程
- 下一篇: ASP建立MYSQL数据库的连接
-= 资 源 教 程 =-
文 章 搜 索