请教关于搜索后翻页不对的问题,请高手们指教

yinxun 2017-08-09 03:11:26
网上下了一个简易的电话本搜索程序,准备改成单位内部的一个查询系统,但是有如下问题:

1、IIS架设内网网址为:http://172.20.22.55/test/

我在数据库里一共放了30条记录,每20条翻页,所以30条显示2页,其中有22条我把固话改为了110

第二页的url是http://172.20.22.55/test/index.asp?page_f=2


2、点击搜索,http://172.20.22.55/test/search.asp,输入110去查询,查出来肯定是22条结果


3、如图,显示有22条结果,url显示http://172.20.22.55/test/index.asp

然后点翻页,还有两条在第二页,点了以后就变成了http://172.20.22.55/test/index.asp?page_f=2,变成了所有数据的第二页,而不是搜索结果22条里面的第二页



问题我知道在哪里,就是不知道怎么改,实在是不会,现将index.asp和search.asp的代码贴出来,请大侠帮忙看看,非常感谢


此为index.asp

<!--#include file="conn.asp"-->
<title>本地便民电话查询平台V1.0beta</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
<style type="text/css">
<!--
td {
font-size: 12px;
}
-->
</style>
<style type="text/css">
<!--
a:visited {
color: #333333;
text-decoration: none;
}
a:hover {
color: #000000;
text-decoration: underline;
}
a:link {
color: #333333;
text-decoration: none;
}
-->
</style>
<%if request("action")="del" then
sql="delete * from phone where id="&trim(request("id"))
conn.execute sql
end if
%>
<%
'--------------------每页显示数据数量-----------------------
if pagef_count<1 then
pagef_count=10
end if

page_f=request.querystring("page_f")'读取页

if request.querystring("Submit")<>"" then
page_count=cint(request.querystring("pagecount"))'显示页数
if page_count="" or page_count<=0 or not isnumeric(page_count) then
page_count=20
end if
session("pages_count")=page_count
else
if not isempty(session("pages_count")) then
page_count=session("pages_count")
else
page_count=20
end if
end if
'--------------------读 取 库-----------------------
set rs=server.createobject("adodb.recordset")
if request("search")<>"" then
sql="select * from phone where "&request("select")&" like '%"&request("search")&"%' order by id desc"
else
if request("pagefl")="" then
sql="select * from phone order by id desc"
else
sql="select * from phone where zlfl="&trim(request("pagefl"))
end if
end if
rs.open sql,conn,1,3
if rs.eof then
%>
<body bgcolor="#CCCCCC" leftmargin="20"><p> </p>

<%
response.end
end if
rs.PageSize=page_count
rs.CacheSize=page_count
if page_f="" or not isnumeric(page_f) then
page_f=1
end if
page_f=cint(page_f)
if page_f<=0 or page_f>rs.pagecount then
page_f=1
end if
page_f=cint(page_f)
rs.absolutepage=page_f
'response.write page_f &"<br>"
'response.write page_count &"<br>"
'response.write rs.pagecount &"<br>"
'response.write rs.recordcount
%>
<style type="text/css">
<!--
.unnamed1 {
padding-left: 3px;
}
-->
</style>
<body bgcolor="#CCCCCC" leftmargin="20"><p> </p><table width="980" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
<tr>
<td width="781" bgcolor="#0099CC">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="3%"> </td>
<td width="61%" height="38"><img src="images/0249.gif" width="32" height="32" align="absmiddle"> <strong>本地114查号平台</strong></td>
<td width="36%"><img src="images/0002.gif" width="23" height="23" align="absmiddle">
<a href="#" onClick="MM_openBrWindow('news_add.asp','','width=330,height=260')">登记电话</a>  <img src="images/0044.gif" width="23" height="23" align="absmiddle">
<a href="search.asp">查询电话</a>
</td>
</tr>
</table></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24"> </td>
</tr>
</table>
<table width="886" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="25">图标:
<img src="images/2.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=1">常用电话</a>
<img src="images/3.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=2">生活服务</a>
<img src="images/duty.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=3">休闲娱乐</a>
<img src="images/tx.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=4">餐饮住宿</a>
<img src="images/2.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=5">电脑网络</a>
<img src="images/2.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=6">教育培训</a>
<img src="images/3.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=7">婚庆礼仪</a>
<img src="images/duty.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=8">建材家居</a>
<img src="images/tx.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=9">商家企业</a>
<img src="images/tx.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=10">政府机关</a>
【<a href="index.asp"><b>显示所有</b></a>】</td>
</tr>
</table>
<table width="895" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#666666">
<tr bgcolor="#DFEFFF">
<td width="15%" height="24"> <div align="center"><font color="#666666"><strong>名 称</strong></font></div></td>

<td width="15%" height="24"> <div align="center"><font color="#666666"><strong>固 话</strong></font></div></td>
<td width="10%" height="24"> <div align="center"><font color="#666666"><strong>手 机</strong></font></div></td>
<td width="25%" height="24"> <div align="center"><font color="#666666"><strong>地 址</strong></font></div></td>
<td width="15%" height="24"> <div align="center"><font color="#666666"><strong>登 记</strong></font></div></td>
</tr>
</table>
<%
'-----------------------------------------------------
if (page_f mod pagef_count)>0 then'page_ff为页码
page_ff=int(page_f / pagef_count)+1
else
page_ff=page_f/pagef_count
end if
pagef_first=page_ff*pagef_count-pagef_count+1'pagef_first页码开始号
if rs.pagecount-pagef_first >pagef_count then
pagef_last=pagef_first+pagef_count-1'pagef_last页码结束号
else
pagef_last=rs.pagecount
end if
'显示页码开始
for i=pagef_first to pagef_last
if not i=page_f then
else
end if
next
if not page_f=rs.pagecount then
end if
i=1
a=1
for i=1 to page_count
'------------------------循环内容------------------------
%> <table width="695" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="2"> </td>
</tr>
</table>
<table width="895" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#666666">
<tr bgcolor="#F3F3F3">
<td width="15%" height="24" bgcolor="#F6F6F6"> <img src="images/modi_1.gif" width="8" height="1"><img src="<%if rs("zlfl")=1 then%>images/2.gif<%elseif rs("zlfl")=2 then%>images/3.gif<%elseif rs("zlfl")=3 then%>images/duty.gif<%else%>images/tx.gif<%end if%>" width="15" height="15" align="absmiddle">
<%=rs("name")%></td>
<td width="15%" height="24" bgcolor="#FFFFFF">
<div align="center"><%=rs("officetel")%></div></td>
<td width="10%" height="24" bgcolor="#FFFFFF">
<div align="center"><%=rs("cellphone")%></div></td>
<td width="25%" height="24" bgcolor="#FFFFFF">
<div align="center"><%=rs("email")%></div></td>
<td width="15%" height="24" bgcolor="#FFFFFF">
<div align="center"><%=rs("qq")%></div></td>
</tr>
</table>
<%
'------------------------------------循环体
rs.movenext
if rs.eof then exit for
next
%>
<table width="895" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="878" height="30"><div align="right">总<font color=red><b><%=Rs.recordcount%></b></font>条
<%
'----------------------计算分页
if not page_f=1 then
%>
<a href="<%=aspfile & "?page_f=1"%>"><<</a> <a href="<%=aspfile & "?page_f=" & page_f-1%>"><</a>
<%
end if
'response.write pagef_first & "<br>"
'response.write pagef_last & "<br>"
for i=pagef_first to pagef_last
if not i=page_f then
%>
<a href=<%=aspfile & "?page_f=" & i%>><%=i%></a>
<%
else
response.write "<strong><font color=#FF0000>" & i & "</font></strong>"
end if
next
if not page_f=rs.pagecount then
%>
<a href="<%=aspfile & "?page_f=" & page_f+1%>">></a> <a href="<%=aspfile & "?page_f=" & rs.pagecount%>">>></a>
<%
end if
rs.Close
set rs=nothing
%>
</div>
[本地114便民电话平台V1.0beta]</td>
<td width="17"> </td>
</tr>
</table> </td>
</tr>
</table>
...全文
267 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yinxun 2017-08-12
  • 打赏
  • 举报
回复
感谢大哥 已给分
  • 打赏
  • 举报
回复
分页链接要附带上参数 <% pms="&select="&request("select")&"&search="&request("search")&"&pagefl="&request("pagefl") '----------------------计算分页 if not page_f=1 then %> <a href="<%=aspfile & "?page_f=1"&pms%>"><<</a> <a href="<%=aspfile & "?page_f=" &( page_f-1)&pms%>"><</a> <% end if 'response.write pagef_first & "<br>" 'response.write pagef_last & "<br>" for i=pagef_first to pagef_last if not i=page_f then %> <a href=<%=aspfile & "?page_f=" & i&pms%>><%=i%></a> <% else response.write "<strong><font color=#FF0000>" & i & "</font></strong>" end if next if not page_f=rs.pagecount then %> <a href="<%=aspfile & "?page_f=" & (page_f+1)&pms%>">></a> <a href="<%=aspfile & "?page_f=" & rs.pagecount&pms%>">>></a> <% end if
yinxun 2017-08-09
  • 打赏
  • 举报
回复
此为search.asp

 <script language="JavaScript" type="text/JavaScript">

<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<style type="text/css">
<!--
td {
	font-size: 12px;
}
-->
</style>
<style type="text/css">
<!--
a:visited {
	color: #333333;
	text-decoration: none;
}
a:hover {
	color: #000000;
	text-decoration: underline;
}
a:link {
	color: #333333;
	text-decoration: none;
}
-->
</style>
<body bgcolor="#CCCCCC" leftmargin="20"><p> </p>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr>
    <td width="781" bgcolor="#0099CC"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="3%"> </td>
          <td width="61%" height="38"><img src="images/0249.gif" width="32" height="32" align="absmiddle"> <strong>电话记录列表</strong></td>
          <td width="36%"><img src="images/0002.gif" width="23" height="23" align="absmiddle"> 
            <a href="#" onClick="MM_openBrWindow('news_add.asp','','width=330,height=260')">新增记录</a>  <img src="images/0044.gif" width="23" height="23" align="absmiddle"> 
            <a href="search.asp">查找记录 </a>
          </td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="24"> </td>
        </tr>
      </table>
      <table width="886" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="25">图标: <img src="images/2.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=1">常用电话</a> <img src="images/3.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=2">生活服务</a> <img src="images/duty.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=3">休闲娱乐</a> <img src="images/tx.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=4">餐饮住宿</a> <img src="images/2.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=5">电脑网络</a> <img src="images/2.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=6">教育培训</a> <img src="images/3.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=7">婚庆礼仪</a> <img src="images/duty.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=8">建材家居</a> <img src="images/tx.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=9">商家企业</a> <img src="images/tx.gif" width="15" height="15" align="absmiddle"> <a href="?pagefl=10">政府机关</a> 【<a href="index.asp"><b>显示所有</b></a>】</td>
        </tr>
      </table>
      <table width="895" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#666666">
        <tr bgcolor="#DFEFFF">
          <td width="15%" height="24"><div align="center"><font color="#666666"><strong>名 称</strong></font></div></td>
          <td width="15%" height="24"><div align="center"><font color="#666666"><strong>固 话</strong></font></div></td>
          <td width="10%" height="24"><div align="center"><font color="#666666"><strong>手 机</strong></font></div></td>
          <td width="25%" height="24"><div align="center"><font color="#666666"><strong>地 址</strong></font></div></td>
          <td width="15%" height="24"><div align="center"><font color="#666666"><strong>登 记</strong></font></div></td>
        </tr>
      </table>
      <table width="695" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="2"> </td>
        </tr>
      </table>
      <table width="695" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#666666">
        <tr bgcolor="#F3F3F3"> 
          <td height="24" bgcolor="#F6F6F6"><div align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <form name="form1" method="post" action="index.asp">
          <tr> 
            <td height="50"> 
              <div align="center"> 
                <select name="select">
                  <option value="name" selected>名 称</option>
                  <option value="officetel">固 话</option>
                  <option value="cellphone">手 机</option>
                  <option value="email">地 址</option>
                  <option value="qq">日 期</option>
                </select>
                <input name="search" type="text" id="search">
                <input type="submit" name="Submit" value="提交">
              </div></td>
          </tr>
        </form>
      </table></div></td>
        </tr>
      </table>
      
      <table width="695" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="678" height="30"><div align="right">
            [本地114便民电话平台V1.0beta] </div></td>
          <td width="17"> </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>

28,409

社区成员

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

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