查询结果分页显示 在线等待高分

gwzwx 2003-05-29 01:03:21
例如:
表名:1.mdb
字段名:xm 姓名
dwmc 工作单位
大概有2万条记录 有相同单位名。即一个单位有很多人,所以需要分页。
查询某人或某单位可以显示结果并分页。
希望各位高手指点。
...全文
37 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
gwzwx 2003-05-29
  • 打赏
  • 举报
回复
需要有两个页面。
1.<HTML>
<HEAD>
<TITLE>1</TITLE>
</HEAD>
<BODY>
<FORM METHOD="POST" ACTION="1.asp">
<P>请选择搜寻类别:
<INPUT TYPE="RADIO" NAME="Kind" VALUE="姓名">姓名
<INPUT TYPE="RADIO" NAME="Kind" VALUE="工作单位">工作单位


<P>请输入关键字:<INPUT TYPE="TEXT" NAME="Keyword" SIZE="40"></P>
<INPUT TYPE="SUBMIT" VALUE="开始查询">
<INPUT TYPE="RESET" VALUE="重新输入">
</FORM>
</BODY>
</HTML>
第二个
1.asp 不知道怎么写了。我想开头应该是这样的吧                      <%
Dim Kind, Keyword
Kind = Request("Kind") '读取所选择的搜索类别
Keyword = Request("Keyword") '读取所输入的关键字
%>
然后根据这两个进行搜索然后把结果分页。希望那位高手写一下这个1.asp
xjy521 2003-05-29
  • 打赏
  • 举报
回复
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="dbcon.asp" -->

<%currentpage=request.QueryString("currentpage")
sontypeid=request.QueryString("sontypeid")

'############################### 定义变量 ########################################
set rs=server.CreateObject("adodb.recordset")
sql="select * from gongqiou where sontypeid="&sontypeid
sql=sql&" order by ID desc"
rs.open sql,conn,3,2
rs_count=rs.recordcount
sizepage=3

if rs.eof then
response.Redirect("read.asp")
Response.End
end if
'################################## 格式参数 ##########################################
if currentpage="" then currentpage=1 end if
if (currentpage*sizepage)>rs_count then
if (rs_count mod sizepage)=0 then
currentpage= (rs_count\ sizepage)
else
crrentpage= (rs_count \sizepage)+1
end if
end if

'################################ 移动指钟 #############################
if currentpage=1 then
rs.MoveFirst
else
rownum=(currentpage-1)*sizepage
if rownum < rs_count then
rs.Move rownum
else
Response.Write "没有记录了!"
Response.End
end if

end if



'################################## 显示记录 ##################################
%><html>
.........................................省略..




<% '######################## 翻页 ################################
if currentpage >1 then %>
<font color="#FF6600" size="2"><a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=1">首页</a>
<a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=<%=(currentpage-1)%>">上一页</a> </font>
<% else%>
<font color="#FF6600" size="2">首页
上一页 </font>
<%
end if
if (rs_count mod sizepage) =0 then
last= rs_count\sizepage
else
last=(rs_count \sizepage)+1
end if

if currentpage >= last then %>
<font color="#FF6600" size="2">下一页
尾页 </font>
<%else%> <font color="#FF6600" size="2"><a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=<%=(currentpage+1)%>">下一页</a>
<a href="gongqiou.asp?sontypeid=<%=sontypeid%>¤tpage=<%=last%>">尾页 </a></font>

<% end if%>
<font color="#6633FF" size="2">一共有<%=last%>页,这是第<%=currentpage%>页 一共有<%=rs_count%>条信息</font>



</body>
</html>
<% rs.close
set rs=nothing
conn.close
set conn=nothing
%>
xjy521 2003-05-29
  • 打赏
  • 举报
回复
学习
andy2001p 2003-05-29
  • 打赏
  • 举报
回复
<%'开始分页
Const MaxPerPage=12
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
if namekey="" then
.....

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
showContent
showpage totalput,MaxPerPage,"editdingdan.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"editdingdan.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"editdingdan.asp"
end if
end if
end if

sub showContent
dim i
i=0

%>
...... <%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</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
'//////////////////
if namekey="" then
Response.Write "<form method=Post action="&filename&"?zhuangtai="&zhuangtai&">"
else
Response.Write "<form method=Post action="&filename&"?zhuangtai="&zhuangtai&"&namekey="&namekey&">"
end if
'//////////////////
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首页 上一页</font> "
Else
'///////////////////
if namekey="" then
Response.Write "<a href="&filename&"?page=1&zhuangtai="&zhuangtai&" class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="¤tPage-1&"&zhuangtai="&zhuangtai&" class='contents'>上一页</a> "
ELSE
Response.Write "<a href="&filename&"?page=1&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>首页</a> "
Response.Write "<a href="&filename&"?page="¤tPage-1&"&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>上一页</a> "
end if
'//////////////////
End If

If n-currentpage<1 Then
Response.Write "<font class='contents'>下一页 尾页</font>"
Else
'////////////////////////
if namekey="" then
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&zhuangtai="&zhuangtai&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&zhuangtai="&zhuangtai&" class='contents'>尾页</a>"
else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>"
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&zhuangtai="&zhuangtai&"&namekey="&namekey&" class='contents'>尾页</a>"
end if
'/////////////////////
End If
Response.Write "<font class='contents'> 页次:</font><font class='contents'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"笔订单 "&maxperpage&"笔订单/页</font> "
Response.Write "<font class='contents'>转到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&">"
Response.Write " <input type='submit' class='contents' value='GO' name='cndok'></form>"
End Function
%>
lqflsh 2003-05-29
  • 打赏
  • 举报
回复
<html>
<title>分页技术</title>
<head>
<%
const MaxPerPage=25
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
%>
</head>
<body bgcolor=Thistle>
<P align=center><FONT face=方正舒体><FONT size=5><STRONG>实例   
分页技术</STRONG>

<%
conn = "DBQ=" + server.mappath("1.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
sql = "SELECT * FROM mytable"
set rs=server.createobject("adodb.recordset")
rs.open SQL,conn,1,1
rs.MoveFirst
rs.pagesize=MaxPerPage
howmanyfields=rs.Fields.Count-1

If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If

if rs.eof then
response.write "<p align='center'> ERROR!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if

dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
</FONT></FONT></P>
<P>PAGE <%=currentpage%> OF <%=n%> 共<%=rs.recordcount%> 纪录
<% k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='index.asp?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(k-1)+"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='index.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
response.write "[<b>"+"<a href='index.asp?page="+cstr(n)+"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
%>

</P>

<TABLE border=1 align=center>
<tr>
<%
for i= 0 to howmanyfields%>
<TD><B><%=rs(i).name%></B></TD>
<%
next
i=0
do while not rs.eof and i<maxperpage%>
<tr align=middle>
<%for j=0 to howmanyfields%>
<td>
 <%=rs(j)%> 
</td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</TABLE>
<%
end if
rs.close
set rs=nothing
%>
</body>
</html>
jshao 2003-05-29
  • 打赏
  • 举报
回复
dim intcurrentpage,intpagesize,inti,inttotalpage,inttotalitem,intmax,strpost
strpost="&strsql=" & replace(replace(strsql," ","%20"),">",">")
objrs.movelast
inttotalitem=objrs.bookmark
if request("intcurrentpage")>0 then
intcurrentpage=cint(request("intcurrentpage"))
else
intcurrentpage=1
end if
intpagesize=10
objrs.pagesize=intpagesize
inttotalpage=objrs.pagecount
objrs.absolutepage=intcurrentpage
response.write("<div align=right size=2>")
'response.write("<label onclick=""return printPreview()""><b>Print</b></label> ")
if intcurrentpage>1 then
response.write("<a href=addin.asp?intcurrentpage=1" & strpost & "><font size=2>First Page</font></a>")
else
response.write("<font size=2>First Page</font>")
end if
response.write(" | ")
if intcurrentpage>1 then
response.write("<a href=addin.asp?intcurrentpage=" & intcurrentpage-1 & strpost & "><font size=2>Previous Page</font></a>")
else
response.write("<font size=2>Previous Page</font>")
end if
response.write(" | ")
if intcurrentpage<objrs.pagecount then
response.write("<a href=addin.asp?intcurrentpage=" & intcurrentpage+1 & strpost &"><font size=2>Next Page</font></a>")
else
response.write("<font size=2>Next Page</font>")
end if
response.write(" | ")
if intcurrentpage<objrs.pagecount then
response.write("<a href=addin.asp?intcurrentpage=" & inttotalpage& strpost & "><font size=2>Last Page</font></a>")
else
response.write("<font size=2>Last Page</font>")
end if
if intpagesize*intcurrentpage<inttotalitem then
intmax=intpagesize*intcurrentpage
else
intmax=inttotalitem
end if
response.write("<font size=2>   |  Items: " & intpagesize * (intcurrentpage-1)+1 & " to " & intmax & " of " & inttotalitem & " |</font>" )
response.write("<font size=2>  Pages: " & intcurrentpage & " of " & inttotalpage & "</font>")
response.write("</div>
参考一下吧
tracy_qd 2003-05-29
  • 打赏
  • 举报
回复
某人
select * from [yourtablename]
某单位
select * from [yourtablename] order by dwmc
960379 2003-05-29
  • 打赏
  • 举报
回复
好久没有看到这么简单的问题了。这个网站上好多分页的问题,很多回答都很好,自己搜索一些吧。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧