社区
ASP
帖子详情
分页老问题,不一定好解决,相信吗?
xiaojun2000
2001-05-18 05:53:00
加精
我的数据太少了,我想让其分为两列排列,且具有分页的功能。我目前只做到这一点,要不只可以分页,要不只可以分列,能否两方面结合到一起呢?
...全文
146
5
打赏
收藏
分页老问题,不一定好解决,相信吗?
我的数据太少了,我想让其分为两列排列,且具有分页的功能。我目前只做到这一点,要不只可以分页,要不只可以分列,能否两方面结合到一起呢?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
xiaojun2000
2001-05-20
打赏
举报
回复
不好意思,现在马上加分
freezwy
2001-05-19
打赏
举报
回复
本问题已经有很多人问,所以,今天作了一个测试程序,测试成功,代码如下:
关键问题:
1.根据每页的记录数量计算出需要的表格行
2.根据HTML作出结果,其实这个问题的根本就是HTML算法显示.
源代码如下:记住给分.
---------------------
测试数据表如下:access2000
id autoincrement
vname char
vcontent char
=====================================
query.asp
<html>
<head>
<title>查询</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel=stylesheet href=../style.css>
</head>
<body bgcolor="#FFFFFF">
<p> </p>
<p> </p>
<hr align=center color=#FFE1A4 noShade size=1 >
<p> </p><table width="39%" border="1" height="1" cellspacing="0" bordercolorlight="#000000" bordercolordark="#ffffff" align="center" cellpadding="0">
<tr bgcolor="#F5F3FA" valign="top">
<td class="font9" bgcolor="#F5F3FA">
<div align="center">一般搜索</div>
</td>
</tr>
<tr >
<td class="font9" height="17">
<form name="form1" method="post" action="result.asp" >
<div align="center">姓 名 :
<input type="text" name="vname" class="smallInput" maxlength="20">
<input type="submit" style="color:#000000;BACKGROUND-COLOR:#DED1EF; FONT-SIZE: 9pt;height:22" value="搜索" name="submit1" class="buttonface" >
</div>
</form>
</td>
</tr>
</table><p> </p><hr align=center color=#FFE1A4 noShade size=1 >
<p align="center">Written by freezwy</p>
==========================================================================
result.asp
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("test.mdb")
' const maxperpage=10
maxperpage=10
'定义每页的记录数量
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
'关键是这里
z=maxperpage mod 2
if z<>0 then
y=maxperpage\2+1
else
y=maxperpage/2
end if
'y是这个页面双行显示的表格的行数
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title>查询结果</title>
<script language="javascript">
function opennew(id)
{window.open("rcxx.asp?id="+id,"","height=500,width=570,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no,left=100,top=10");
}
</script>
<link rel=stylesheet href=../style.css>
<body bgcolor="#FFFFFF">
<div align="center">
<hr align=center color=#FFE1A4 noShade size=1 >
<table border="0" cellspacing="1" width="98%" >
<tr>
<td width="100%" height="96">
<%
vname=trim(request("vname"))
sql="select * from test where instr(vname,'"&vname&"')>0 order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof then
response.write "<p align='center'>没有你要找的信息</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
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,"result.asp",vname
showContent
showpage totalput,MaxPerPage,"result.asp",vname
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showpage totalput,MaxPerPage,"result.asp",vname
showContent
showpage totalput,MaxPerPage,"result.asp",vname
else
currentPage=1
showpage totalput,MaxPerPage,"result.asp",vname
showContent
showpage totalput,MaxPerPage,"result.asp",vname
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
i=0
%>
<div align="center">
<table border="1" width="54%" cellspacing="0" cellpadding="1" style="font-size: 9pt" bordercolorlight="#666666" bordercolordark="#FFFFFF">
<tr>
<td width="203" bgcolor="#F5F3FA">姓名</td>
<td width="197" bgcolor="#F5F3FA">说明</td>
<td rowspan=<%=y+1%> width="150"> </td>
<%'这里加上一个空行是为了显示的方便%>
<td width="203" bgcolor="#F5F3FA">姓名</td>
<td width="197" bgcolor="#F5F3FA">说明</td>
</tr>
<tr>
<%
'关键是把<tr>标志放到外边
do while not rs.eof%>
<%if (i mod 2)=0 then%>
<td align=center width="203" height="25">
<a href="javascript:opennew(<%=rs("id")%>)">
<%=replace(rs("vname"),vname,"<font color=red>"&vname&"</font>")%>
</a>
</td>
<td align=center width="197" height="25"><%=rs("vcontent")%></td>
<%else%>
<td align=center width="203" height="25">
<a href="javascript:opennew(<%=rs("id")%>)">
<%=replace(rs("vname"),vname,"<font color=red>"&vname&"</font>")%>
</a>
</td>
<td align=center width="197" height="25"><%=rs("vcontent")%></td>
</tr>
<%end if%>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%></tr>
</table>
</div>
<%
end sub
function showpage(totalnumber,maxperpage,filename,vtype)
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'>分页 "
if CurrentPage<2 then
response.write "首页 上一页 "
else
response.write "<a href="&filename&"?page=1&vname="&vtype&">首页</a> "
response.write "<a href="&filename&"?vname="&vtype&"&page="¤tPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write " 下一页 尾页"
else
response.write "<a href="&filename&"?vname="&vtype&"&page="&(CurrentPage+1)
response.write ">下一页</a> <a href="&filename&"?vname="&vtype&"&page="&n&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"¤tPage&"</font>/"&n&"</strong>页 "
response.write " 共<b>"&totalnumber&"</b>条信息 <b>"&maxperpage&"</b>条信息/页 "
response.write " 转到:<input type='text' name='page' size=4 maxlength=10 class=smallInput value="¤tpage&">"
response.write "<input class=buttonface type='submit' value='Go' name='cndok'></span></p></form>"
end function
%>
</td>
</tr>
</table>
<hr align=center color=#FFE1A4 noShade size=1 >
<p align=center>Written by freezwy</p>
</div>
=======================================================================
最好多加几条记录测试,我这里通过.
freezwy
2001-05-19
打赏
举报
回复
咋不加分呢.好害也忙活着调试了
xiaojun2000
2001-05-18
打赏
举报
回复
能否给一点源码呢?
xmlingo
2001-05-18
打赏
举报
回复
分列是数据显示问题
分页是返回数据行问题
例如一页返回40条记录,只要表格控制好任你分成几列,
JFinal专题之
分页
原理与
解决
方案
JFinal
分页
原理视频教程,该课程详细介绍数据库
分页
原理,自己动手封装前端
分页
组件,然后介绍第三方的js
分页
组件,集成jquery.Pagination插件。
ES 深度
分页
问题
及针对不同需求下的
解决
方案(Deep paging)
1、什么是深度
分页
(Deep paging)? 1.1 ES中from+size
分页
分页
问题
是Elasticsearch中最常见的查询场景之一,正常情况下
分页
代码如实下面这样的: GET order_2290w/_search { "from": 0, "size": 5 } 输出结果如下图: 很好理解,即查询第一页的5条数据。图中数字2即返回的五条文档数据。但是如果我们查询的数据页数特别大,达到什么程度呢?当from + size大于10000的时候,就会出现
问题
,如下图报错信息所示: 报
【sql效率优化】优雅地
解决
mysql深
分页
问题
?
日常需求开发过程中,相信大家对于limit
一定
不会陌生,但是使用limit时,当偏移量(offset)非常大时,会发现查询效率越来越慢。一开始limit 2000时,可能200ms,就能查询出需要的到数据,但是当limit 4000 offset 100000时,会发现它的查询效率已经需要1S左右,那要是更大的时候呢,只会越来越慢。本文将会讨论当mysql表大数据量的情况,如何优化深
分页
问题
,并附上最近的优化慢sql
问题
的案例伪代码。先看看表结构(随便举了个例子,表结构不全,无用字段就不进行展示了) 假
分页
查询的重复数据
问题
数据的增删改,以及数据的缓存,都可能会对mysql的结果输出顺序造成影响。所以,极有可能执行完(1)后返回1,2,3,4,执行完(2)后返回4,5,6,7的情况,造成部分数据重复查询,部分数据漏查的情况(ORACLE默认排序也会有同样的
问题
)。(3)如果要避免有删除、插入对查询结果集造成影响,则需要利用上一次
分页
查询结果作为下一次查询的条件,不断对查询结果进行过滤,来确保得到正确的查询结果。在执行完(1)后,返回id值为1,2,3,4的数据,执行完(2)后返回id值为5,6,7,8的数据。
Java开发 -
分页
查询初体验
在上一篇,我们对es进行了深入讲解,相信看过的小伙伴已经能基本掌握es的使用方法,我们知道,es主要针对的是搜索条件,在这方面es具有无可比拟的优势,但我们也会注意到,有时候搜索条件过于宽泛的时候,搜索结果集也将是非常庞大的,不仅服务器接口压力大,用户等的也很为难,为了
解决
这一
问题
,必须要对返回的数据进行处理,此时,
分页
就出现了,接下来,博主讲带两大家了解查询时的
分页
问题
,并
解决
这个
问题
。
ASP
28,391
社区成员
357,060
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章