中国结最简单的编法:哪位高手帮我详细的解释一下ASP中的分页

来源:百度文库 编辑:高考问答 时间:2024/04/29 08:09:43
例子如下,哪位能帮我详细地解释一下。。我会追加50分

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!-- #include file="cnn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charstet=gb2312">
<title>无标题文档</title>
</head>
<%
dim ssql,bt,sj
ssql="select * from 新闻"
rst.open ssql,cnn,1,3
%>

<body>
<table width="536" border="2" cellspacing="2" cellpadding="2">
<tr align="center">
<td width="321">新闻标题</td>
<td width="193">发表时间</td>
</tr>
<%
pmcount=5 '定义每页显示几条记录
rcount=rst.recordcount '这个命令是返回当前有多少条符合条件的记录总数
if pmcount="" or isempty(pmcount) or pmcount<1 then
pmcount=5
end if
rst.pagesize=pmcount '设定每页显示的数量
mpage=rst.pagecount '一共显示页数
pageno=request("pageno") '获取当前显示第几页
if isempty(pageno) or cint(pageno)<1 or cint(pageno)>mpage then
pageno=1
end if
if not rst.eof or not rst.bof then
rst.absolutepage=cint(pageno) '把当前页保存在rst.absolutepage当中。
loopno=pmcount
do while not rst.eof and loopno>0

bt=rst("标题")
sj=rst("时间")
%>

<tr>
<td><a href=xianshi.asp?id=<%=rst("id")%> target="_blank"><% response.write (bt) %></a></td>
<td><% response.write (sj) %></td>
</tr>
<%
rst.movenext
loopno=loopno-1
loop
rst.close
%>
<tr align="center">
<td height="29" colspan="2">

<%
if cint(pageno)<2 then
response.write " 首页 | 上一页"
else
response.write "<a href=index.asp?pageno=1>首页</a> | "
response.write "<a href=index.asp?pageno="&pageno-1&">上一页</a>"
end if
%>

|
<%
if cint(mpage-pageno)<1 then
response.write "下一页 | 尾页"
else
response.write "<a href=index.asp?pageno="&pageno+1&">下一页</a> | "
response.write "<a href=index.asp?pageno="&mpage&">尾页</a>"
end if
%>
| 共计<%=cstr(rcount)%>主题<%=cstr(pageno)&"/"&cstr(mpage)&"页"%></td>
</tr>
</table>
<p>
<%end if%>
</p>
<table width="450" border="2" cellspacing="2" cellpadding="2">
<tr align="center">
<td><a href="guanli.asp" >管理新闻</a></td>
<td> </td>
</tr>
</table>
</body>
</html>

这都是死代码,你只要用就可以了,不必深究!