续:******朋友(denghai)帮忙,高分查看这段代码:查询关键字分页显示时,第一页正常,从第二页开始,就按查询所有记录显示了?******

rolandzhang 2003-02-21 09:00:20
http://appserver/search.asp
企业客户基本資料文档
--------------------------------------------------------------------------------
客户名称: 公司 ------ 查询
首页显示:
http://appserver/search.asp


客户编号 客户名称 負責人 聯系人 EMAIL 网址 单位性质 地址 联系方式
搜索:公司
27003 新西兰凯威公司 蔡莉 上鼎1713 2659581 2659581(fax)
......

27016 司达福纺织有限公司 赵青 上鼎1711 2802532 2802536(fax)
本库共435个记录 首页 上一页下一页 尾页页次:1/44页 10个记录/页 第1页...第44页

第二页 显示:
http://appserver/search.asp?page=2&strname=公司

本库共689个记录 首页上一页下一页 尾页页次:2/69页 10个记录/页 第2页 ... 第69页

第3页(从此页开始,地址中strname没有值了
http://appserver/search.asp?page=3&strname=

本库共689个记录 首页上一页下一页 尾页页次:3/69页 10个记录/页 第3页 ... 第69页

http://appserver/search.asp?page=4&strname=

本库共689个记录 首页上一页下一页 尾页页次:4/69页 10个记录/页 第4页 ... 第69页

......

...全文
137 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
denghan 2003-02-27
  • 打赏
  • 举报
回复
'''以下是关于分页显示的函数,可反复调用
sub showContent
dim i
i=0
do while not rs.eof
%>



<tr>
<td width="64"> <font size="2"> <%=rs("contactid")%> </font> </td>
<td width="57"> <font size="2"> <%=rs("name")%> </font> </td>
<td width="53"> <font size="2"> <%=rs("corporation")%> </font> </td>
<td width="49"> <font size="2"> <%=rs("contact")%></font></td>
<td width="40"> <font size="2"> <%=rs("email") %></font></td>
<td width="38"> <font size="2"> <%=rs("webaddr") %></font></td>
<td width="85"> <font size="2"> <%=rs("occupation")%></font></td>
<td width="67"> <font size="2"> <%=rs("zipcode")%></font></td>
<td width="313"><font size="2"><%=rs("allphn")%> </font></td>
</tr>
<tr>
<td colspan="9"><%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
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
response.write "<form method=Post action="&filename&"?name="& strname & "></font>"
response.write "<p align='middle'><font color='black'>本类共<font color='red'>"&totalnumber&"</font>个 </font>"

if CurrentPage<2 then
response.write "<font color='black'>首页 上一页</font>"
else
response.write "<font color='blue'><a href="&filename&"?page=1&name="& strname & "></font><font color='red'>首页</font></a>"
response.write "<font color='blue'><a href="&filename&"?page="¤tPage-1&"&name=" & strname & "></font><font color='red'>上一页</font></a>"
end if
''''以下是按不同情况显示分页页码及传参数
if n-currentpage<1 then
response.write "<font color='black'>下一页 尾页</font>"
else
response.write "<font color='blue'><a href="&filename&"?page="&(CurrentPage+1)&"&name=" & strname & "></font>"
response.write "<font color='blue'>下一页</a> </font><a href="&filename&"?page="&n&"&name=" & strname & "><font color='blue'>尾页</font></a>"
end if
response.write "<font color='black'>页次:<font color=red>"¤tPage&"</font>/"&n&"页</font> "
response.write "<font color='red'>"&maxperpage&"</font>个记录/页 "
%>

<select name='page' size='1' style="border:1px solid #007fbb; font-size: 9pt; color:#000000; background-color:#ceefff" onChange='javascript:submit()'>
<%for i = 1 to n%>
<option value='<%=i%>' <%if cint(currentPage)=cint(i) then%> selected <%end if%>>第<%=i%>页</option>
<%next%>
</select>
<%
response.write "</form>"
end function
%></td></table>
</body>
</html>
denghan 2003-02-27
  • 打赏
  • 举报
回复
<%
''''''''''连接数据库

dim conn,connst
'connstr= "provider=oraoledb.oracle.1;persist security info=true;user id=iagent;password=ia;data source=app_yong"
'set conn=server.createobject("adodb.connection")
'conn.open connstr

'''''''''''''''''''''''''''''''''''''''''''''
'为方便调试,我把它换成了ACCESS
connstr="DBQ="+server.mappath("db3.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
if trim(request("name"))="" then
strname=""
else
strname=trim(request("name") )'关键字
end if
MaxPerPage=2 '每页最多显示的记录数
if not isempty(request("page")) then
currentPage=cint(request("page")) '由上页传过来的页数
else
currentPage=1 '如果页数为空则为第一页
end if
%>
<html>
<head>
<title></title>
</head><body><form Action="search.asp" Method="Post">
<table border="0" cellpadding="0" cellspacing="0" width="100%" topmargin="0"><tr>
<td>           <font face="新細明體" size="5"><strong>                              
企业客户基本資料文档</strong></font>          
<hr size="1" color="#000080">
<font COLOR="Red"><font size="2">            
</font></font> 客户名称:
<input name="name" type="text" id="name" size="20">
<input type="submit" name="Submit" value="查询">
</td>
</tr>

</table> </form>
<table border="1" cellpadding="0" cellspacing="0" width="100%" bordercolor="#999999">
<tr> <!-显示表头!->
<td align=center width="64"><b><font color="#800000" size="2">客户编号</font></b></td>
<td align=center width="57"><b><font color="#800000" size="2">客户名称</font></b></td>
<td align=center width="53"><b><font color="#800000" size="2">負責人</font></b></td>
<td align=center width="49"><b><font color="#800000" size="2">聯系人</font></b></td>
<td align=center width="40"><b><font color="#800000" size="2">EMAIL</font></b></td>
<td align=center width="38"><b><font color="#800000" size="2">网址</font></b></td>
<td align=center width="85"> <b> <font color="#800000" size="2"> 单位性质</font>
</b></td>
<td align=center width="67"> <b> <font color="#800000" size="2">邮编 </font>
</b></td>
<td align=center width="313"> <b> <font color="#800000" size="2"> 联系方式</font>
</b></td>
</tr>
<%
response.write "搜索:<font color=blue>"&strname&"</font>"
set rs=server.createobject("adodb.recordset")
'根据不同情况创建并打开记录集
if strname="" then
sql="select contactid,name,corporation,contact,email,webaddr,occupation, zipcode,allphn from contact"
else
sql="select contactid,name,corporation,contact,email,webaddr,occupation, zipcode,allphn from contact where name like '%"&strname&"%'"
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then '如果记录集为空
Response.Write "<font color=red>抱歉,没有搜索到相关的资料!</font>"
else '不为空
'Response.Write "共搜索到" & rs.RecordCount & "条相关资料,共"& rs.PageCount &"页,每页"& rs.PageSize &"条(当前第"& Page &"页)"
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,"search.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"search.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"search.asp"
end if
end if
rs.close
end if
zhusuhao 2003-02-21
  • 打赏
  • 举报
回复
用 url?参数 的方式就行了!
ardong 2003-02-21
  • 打赏
  • 举报
回复
建义用Hidden将查询的值保存,这样条件才不会丢掉。
gshope 2003-02-21
  • 打赏
  • 举报
回复
要把查询条件也传到下一页去。
BrightEye 2003-02-21
  • 打赏
  • 举报
回复
没看你的代码,你试试用session传递strname
whcasp 2003-02-21
  • 打赏
  • 举报
回复
url?page=1&Search1=aaa&Se.....
dhluo 2003-02-21
  • 打赏
  • 举报
回复
for j=1 to pages
response.write("|<a href=seednews.asp?pgno="&j&"&type="&typehere&"&noflag="&flaghere&"&pubtime="&timehere&"&key="&keyhere&"&searchtype="&searchtype&">第"&j&"页</a> ")
next

rolandzhang 2003-02-21
  • 打赏
  • 举报
回复
楼上的朋友们说了这么多方法,能否举李说明,在下谢谢了!

28,391

社区成员

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

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