% Language="VBScript" response.buffer=true Response.Expires=0 if session("pas")<>"pas" then response.redirect "ad_login.asp" end if %>
|
|
<% Language="VBScript"
dim conn
dim connstr
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim sql
dim rs
on error resume next
'打开数据库
set conn=Server.CreateObject("ADODB.Connection")
dbpath=Server.MapPath("lydata/guest.mdb")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&dbpath
set rs=Server.CreateObject("ADODB.Recordset")
'定义每页文章显示数
const MaxPerPage=18
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
sql="select * from ly order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
liuyan=replace(rs("liuyan"),chr(10)+chr(13)," ") if rs.eof and rs.bof then response.write " 还没有任何留言 " else totalPut=rs.recordcount '数据库中留言数totalput 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 showpage totalput,MaxPerPage,"adviewguest.ASP" showContent showpage totalput,MaxPerPage,"adviewguest.ASP" else if (currentPage-1)*MaxPerPage
<% '当显示记录大于maxperpage时结束这页 i=i+1 if i>=MaxPerPage then exit do rs.movenext loop end sub function showpage(totalnumber,maxperpage,filename) '求出当每页18条记录时总共的页数 dim n if totalnumber mod maxperpage=0 then n= totalnumber \ maxperpage else n= totalnumber \ maxperpage+1 end if response.write "" end function %> |
|||||||||||||||||||||||||||