大家帮我吧,这是我的最高分了!!!

ilwdx 2001-07-22 10:48:07
关于一个分页程序:
我想把这个表格每页显示20个(包含了20条记录),并显示多页连接,我也看了很多关于分页的作法,都好复杂,有没有简单一点的?请写详细一点:

<table width="70%" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F7F7F7">
<td width="8%" align="left" valign="top" height="14">
<table width="55" border="0" cellpadding="0" cellspacing="0" height="16">
<tr>
<td width="17" height="19" align="right" valign="top">
<%
if objrs("retell")>10 then
response.write"<img src='pic/xs.gif'>"
else
response.write"<img src='pic/rs.gif'>"
end if
%>
<div align="center"></div>
</td>
<td width="50%" align="left" valign="top" height="19">
<%
select case objrs("ttype")
case 1
B="pic/s3.gif"
case 3
B="pic/s5.gif"
case 2
B="pic/s4.gif"
case 4
B="pic/s6.gif"
end select
response.write"<img src="&B&">"
%>
<div align="center"></div>
</td>
</tr>
</table>
</td>
<td width="55%" height="14" align="left" valign="top" bgcolor="#F7F7F7"><a href=dispins.asp?id=<%=objrs("id")%>><%=objrs("zx")%></a></td>
<td width="4%" height="14" align="left" valign="top"><%=objrs("retell")%></td>
<td width="11%" height="14" align="left" valign="top"><a href=inf.asp?name=<%=objrs("maker")%>><%=objrs("maker")%></a></td>
<td width="22%" height="14" align="left" valign="top" bgcolor="#F7F7F7"><%=objrs("ddate")%></td>
</tr>
</table>



















...全文
16 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
liugys 2001-07-22
下面的已经很模块化了,我加了点注释,改改就能用了

<html>
<head>
<title>搜索结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.3dfont {FILTER: glow(color=#006699,strength=5) shadow(color=aaaaaa,direction:135); POSITION: relative; WIDTH: 100%}
p { font: bold 28px/45px "宋体";color: #ffffff; letter-spacing: 5pt; vertical-align: middle}
td { font-size: 9pt; line-height: 20px}
.table_title { font-weight: bold; color: #FFFFFF; line-height: 22px; background: #006699}
A:link {COLOR: #000000; ; font-weight: normal; text-decoration: none}
A:visited {color: #666666;; text-decoration: none; font-weight: normal}
A:hover {color: #666666; background-color: #FFFFFF; font-weight: normal; letter-spacing: 0px; text-decoration: none}
.table_end { font-weight: normal; color: #000000; background: #DFDFDF; border: 1px #000000}
.tdleft { color: #000000; background: #E7E7E7; text-align: right; font-weight: bold; padding: 2px 5px 2px 2px}
.tdright { color: #000000; background: #FFFFFF; text-align: left; padding: 2px 2px 2px 10px; font-size: 10.5pt}
-->
</style>
</head>
<%
conn1="Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("文科基地数据.mdb")
conn2="Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("期刊目录.mdb")
'生成SQL查询语句
function makesql(sqltemp)
for each form in request.form
forminfo=Request.Form(form)
If forminfo<>"" then
If Right(form,2)="_s" then
sqltemp=sqltemp & " " & left(form,len(form)-2) & " like '%" & forminfo & "%' and "
end if
end if
next
sql=left(sqltemp,len(sqltemp)-5)
end function

'--------------
'显示前后页连接
sub DisplayNav(rs,intpagenum)
filepath=request.ServerVariables("path_info")
if intpagenum>1 then
Response.Write "<a href=""" & filepath & "?PageNo=1" & """>" & "第一条</a>   "
Response.write "<a href=""" & filepath & "?PageNo=" & intpagenum-1 & """>" & "前一条</a>   "
else
Response.Write "第一条   " & "前一条   "
end if
if intpagenum<rs.pagecount then
Response.Write "<a href='" & filepath & "?PageNo=" & intpagenum+1 & "'>" & "下一条" & "</a>   "
Response.Write "<a href='" & filepath & "?PageNo=" & rs.pagecount & "'>" & "最后一条" & "</a>"
else
Response.Write "下一条   " & "最后一条"
end if
end sub

set rs=server.createobject("ADODB.Recordset")
sql="select * from 期刊文献数据 where"
makesql(sql)
'Response.Write sql
'Response.end
rs.Open sql,conn2,1,3
if rs.EOF then
Response.Write "对不起,没有您所查询的数据,<a href='search.htm'><font color=red>点击这里返回</font></a>"
Response.End
Response.Clear
end if
rs.PageSize=15 '每页显示记录数
PageSize=rs.PageSize
PageNo=Cint(Request("PageNo"))
If PageNo < 1 or PageNo = "" Then
PageNo = 1
Else
If PageNo > rs.PageCount then
PageNo=rs.PageCount
end if
End If
rs.AbsolutePage = PageNo '开始页
%>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
<p class=3dfont>期刊目录数据搜索结果</p>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr class="table_title">
<td>
<table width="100%" border="0" class="table_end">
<tr>
<td width="50%"><a href="search.htm"><<返回</a></td>
<td align="right" width="50%">
<%displaynav rs,PageNo%>
</td>
</tr>
</table>
</td>
</tr>
<tr class="table_title">
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="2" height="100%">
<tr>
<td height="14" width="15%" class="tdleft">CN:</td>
<td class="tdright" width="85%"><%=rs("CN")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">题名:</td>
<td width="85%" class="tdright"><%=rs("题名")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">著者1:</td>
<td width="85%" class="tdright"><%=rs("著者1")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">著者2:</td>
<td width="85%" class="tdright"><%=rs("著者2")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">刊名:</td>
<td width="85%" class="tdright"><%=rs("刊名")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">出版年月:</td>
<td width="85%" class="tdright"><%=rs("出版年月")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">页码:</td>
<td width="85%" class="tdright"><%=rs("页码")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">主题词1:</td>
<td width="85%" class="tdright"><%=rs("主题词1")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">主题词2:</td>
<td width="85%" class="tdright"><%=rs("主题词2")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">主题词3:</td>
<td width="85%" class="tdright"><%=rs("主题词3")%></td>
</tr>
<tr>
<td width="15%" class="tdleft">分类名:</td>
<td width="85%" class="tdright"><%=rs("分类名")%></td>
</tr>
</table>
</td>
</tr>
<%for i=0 to PageSize%>
<%rs.MoveNext
if rs.EOF then exit for
next%>
<tr>
<td class="table_title">
<table width="100%" border="0" class="table_end">
<tr>
<td width="50%"><a href="search.htm"><<返回</a> 你查询的记录共有<font color="#FF0000">
<b><%=rs.recordcount%> </b></font>条</td>
<td align="right" width="50%">
<%displaynav rs,PageNo%>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<%
rs.Close
set rs=nothing
%>
</body>
</html>
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2001-07-22 10:48
社区公告
暂无公告