下面是文章显示的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>信息列表</title>
<!--#include file="css.css"-->
<!--#include file="conn.asp"-->
</head>
<body topmargin="1">
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="90" class="unnamed18">
<div align="center"><!--#include file="top.asp"--></div></td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td bgcolor="#98a5d0" align=right>
<% anguage="vbscript"
dim conn
dim connstr
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim sql
dim rs
on error resume next
'打开数据库
set rs=server.createobject("adodb.recordset")
'定义每页文章显示数
const MaxPerPage=10
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
sql="select * from news order by 置顶 desc,id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,3,2
if rs.eof and rs.bof then
response.write "<p align='center'> 还 没 有 任 何 文 章</p>"
else
'数据库中文章数totalput
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
'统计总页数currentpage
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"qtlist.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"qtlist.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"qtlist.asp"
end if
end if
end if
sub showContent
'选择显示数据库内容
%>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td width="594">
</td>
<td width="106" align="center"> </td>
</tr>
</table>
<table width="700" height="20" border="0" align="center" cellspacing="1" class="unnamed12">
<tr class="unnamed14" bgcolor="#FF9966" height="30">
<td width="374" > <div align="center">内 容</div></td>
<td width="77" > <div align="center">发文单位</div></td>
<td width="127" > <div align="center">发文时间</div></td>
<td width="64" > <div align="center">签收状态</div></td>
<td width="58" > <div align="center">签收情况</div></td>
</tr>
<% dim i
i=0
j=0
do while not rs.eof
%>
<tr class="unnamed12" bgcolor="<%if j mod 2=0 then %>#ffcc99<%else%>#ffffff<%end if%>">
<td width="374" height="30" > <a href=qtdisp.asp?disp_id=<%=rs("id")%> target="_blank"><%=left(rs("标题"),20)%></a> <%if rs("附件")<>" " then%> <img src="images/fujian.gif" align="absbottom"> <%end if%></td>
<td width="77" height="30"> <div align="center"><%=rs("发文者")%></div></td>
<td width="127" height="30"> <div align="center"><%=rs("发文日期")%> <%=rs("发文时间")%></div></td>
<td width="64" height="30"> <div align="center">
<%if rs("签收状态")=true then%>
<font color="#FF0000">签收完毕</font>
<%else%>
<font color="#0000FF">签收中</font>
<%end if%>
</div></td>
<td width="58" height="30"> <div align="center"><a href="qtlooker.asp?look_id=<%=rs("id")%>" target="_blank">签收详情</a></div></td>
</tr>
<%
'当显示记录大于maxperpage时结束这页
i=i+1
j=j+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<%
end sub
function showpage(totalnumber,maxperpage,filename)
'求出当总共的页数
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<form method=Post action="&filename&">"
response.write "<p align='center' > <font color='#000080' class='unnamed12'>>>分页</font> "
'显示页数链接的条件
if CurrentPage<2 then
response.write "<font color='#000080' class='unnamed12'>首页 上一页</font> "
else
response.write "<a href="&filename&"?page=1& class='unnamed12'>首页</a> "
response.write "<a href="&filename&"?page="&CurrentPage-1&" class='unnamed12'>上一页</a> "
end if
if n-currentpage<1 then
response.write "<font color='#000080' class='unnamed12'>下一页 尾页</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)
response.write "><font color='#000080' class='unnamed12'>下一页</font></a> <a href="&filename&"?page="&n&"><font color='#000080' class='unnamed12'>尾页</font></a>"
end if
response.write "<font color='#000080' class='unnamed12'> 页次:</font><strong><font color=red class='unnamed12'>"&CurrentPage&"</font><font color='#000080'class='unnamed12'>/"&n&"</strong>页</font>"
response.write "<font color='#000080' class='unnamed12'> 共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/页</font>"
response.write " <font color='#000080' class='unnamed12'>转到:</font><input type='text' name='page' size=4 maxlength=10 class='unnamed12't value="&tpage&">"
response.write "<input class='unnamed12' type='submit' value=' Goto ' name='cndok'>"
response.write " <a href='admin.asp' target='_blank'><font color=red class='unnamed12'>管理登陆</font></a></span></p></form>"
end function
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><!--#include file="bottom.asp"--></td>
</tr>
</table>
</body>
</html>