📄 news.asp
字号:
<!--#include file="top.asp"-->
<%
page_count = 20
MaxPerPage=page_count '分页显示的纪录个数
dim sql
dim rs
dim gstBookID
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
%>
<table width="800" height="403" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="Table_01">
<tr>
<td height="403" colspan="2" valign="top" background="images/right_06.gif"><!--#include file="Tyi86_Left_Other.asp" --></td>
<td width="800" align="right" valign="top" background="images/t_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><img src="images/t_04.gif" width="581" height="29" alt=""></td>
</tr>
<tr>
<%
sql="select * from news ORDER BY id DESC"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
rs.pagesize=MaxPerPage
If trim(Request("Page"))<>"" and IsNumeric(Request("Page")) then
CurrentPage= CLng(request("Page"))
If CurrentPage< 1 then
CurrentPage= 1
ElseIf CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'>还没有添加新闻...</p>"
else
totalPut=rs.recordcount '记录总数
if CurrentPage=1 then
showContent
showpages
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark '移动到开始显示的记录位置
showContent
showpages
else
currentPage=1
showContent
end if
end if
rs.close
end if
set rs=nothing
set conn=nothing
sub showContent
%>
<td height="361" align="center" valign="top" background="images/t_05.gif">
<%
dim i
i=0
do while not (rs.eof or err)
%>
<table width="96%" height="20" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="7%" height="20" align="center" background="images/22.gif"><img src="images/tb.gif" width="6" height="6"></td>
<td width="93%" background="images/22.gif"><a href="new.asp?id=<%response.write rs(0)%>" title="<%=rs("title")%>"><% if Getlen(rs("title"))>48 then%>
<%=LeftStr(rs("title"),45)%>...
<%else%>
<%response.write rs("title")%>
<%end if%></a> [ <%=rs("time")%> ]</td>
</tr>
</table>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
<%end sub%>
<%sub showpages()%>
<table width="96%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="17" align="right" bgcolor="#F7F7F7"><%
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
%>
共有<%=rs.recordcount%>条新闻 每页<%=Page_count%>条新闻
<%
k=currentPage
if k=1 then
response.write " 首页 "& vbCrLf
response.write " 上一页 "& vbCrLf
end if
if k<>1 then
response.write "<a href='News.asp?page=1'> 首页 </a>"
response.write "<a href='News.asp?page="+cstr(k-1)+"'> 上一页 </a>"
end if
if k=n then
response.write " 下一页 "& vbCrLf
response.write " 末页 "& vbCrLf
end if
if k<>n then
response.write "<a href='News.asp?page="+cstr(k+1)+"'> 下一页 </a>"
response.write "<a href='News.asp?page="+cstr(n)+"'> 末页 </a> "
end if
%></td>
</tr>
</table>
<% end sub %>
</td>
</tr>
</table></td>
</tr>
</table>
<!--#include file="end.asp"-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -