找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 141|回复: 11

[求助]请问分页与搜索在一个页面中时分页不正常怎么办?

[复制链接]
发表于 2009-12-26 22:11:19 | 显示全部楼层 |阅读模式 IP:江苏扬州
点击分页按钮时就会显示全部信息而不按搜索关键字显示,这该怎么改?
发表于 2009-12-26 22:11:23 | 显示全部楼层 IP:江苏扬州
我也传递参数了,但还是不行
在首页可以正常实现,接着点击分页就不行了,就会显示全部信息了
回复

使用道具 举报

发表于 2009-12-26 22:11:28 | 显示全部楼层 IP:江苏扬州
conn.asp
-------------------------
<%
'连接数据库开始
dim conn,rs,sql
on error resume next
dbpath=server.mappath("inc/data.mdb")
set conn=server.createobject("adodb.connection")
conn.open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source="&dbpath
'创建记录对象

%>
-----------------------------
funtion.asp
---------------------
<%Function cutPage(sqlStr,Conn,dateNums,pageNums,URLs)'利用ADO分页的函数
Dim sql,Cn,dateNum,pageNum,URL,rsDate
Sql=Trim(sqlStr) '获得sql语句。
Set Cn=Conn '获得数据对象
dateNum=Cint(dateNums) '获得每页得记录数
pageNum=Cint(pageNums) '获得当前页码
URL=Trim(URLs) '获得路径
Set rsDate=Server.CreateObject("ADODB.Recordset")
rsDate.PageSize=dateNum
rsDate.Open Sql,cn,1,1
IF rsDate.Eof Then
Response.Write("<center><font stlye='font-size:14px;' color='#ff0000'>对不起,没有记录!</font></center>")
Else
IF pageNum="" or pageNum<1 Then
pageNum=1
ElseIf pageNum>rsDate.PageCount Then
pageNum=rsDate.PageCount
End IF
rsDate.absolutepage =pageNum
Dim recordHead,recordLast '定义当前页开头记录和结束记录
recordHead=1
If pageNum>1 Then recordHead=dateNum*(pageNum-1)
If pageNum>=rsDate.PageCount Then
recordLast=rsDate.RecordCount
Else
recordLast=dateNum*pageNum
End If
Response.Write("<table width=100% border='0' cellpadding='0' cellspacing='0' style='font-size:12px;'>")

Dim URLa '定义判断输入得URL包含?没有的变量
Dim upPage,downPage,allPage '定义向上和向下翻的变量
Dim allWrite '定义输出
upPage=pageNum-1
downPage=pageNum+1
URLa=Split(URL,"?",-1,1)
If URLa(0)=URL Then
upPage="<a href=" & URL & "?page=" & upPage &" stlye='font-size:12px;'>上一页</a> "
If pageNum=1 Then upPage=""
downPage="<a href=" & URL & "?page=" & downPage &" stlye='font-size:12px;'>下一页</a>"
If pageNum=rsDate.PageCount Then downPage=""
Else
upPage="<a href=" & URL & "&page=" & upPage &" stlye='font-size:12px;'>上一页</a> "
If pageNum=1 Then upPage=""
downPage="<a href=" & URL & "&page=" & downPage &" stlye='font-size:12px;'>下一页</a>"
If pageNum=rsDate.PageCount Then downPage=""
End If
allWrite=upPage & downPage & "  共" & rsDate.PageCount & "页 " & "目前第"& pageNum &"页"
allwrite="<font style='font-size:12px;'>" & allWrite & " 到第<input type='text' style='width:30px;' Name='page' value="& pageNum &">页<input type='submit' value='GO'></font>"


Response.Write("<tr><form name='formPage' method='post' action="&URL&"><td colspan='2' align=right style='font-szie=12px;'>" & allWrite & "</td></form></tr>")
Response.Write("<tr><td colspan='2' align=center>")
Response.Write("<table width=100% border='0' cellpadding='0' cellspacing='0' style='font-size:12px;'>")

Response.Write("<tr bgcolor='#ffdf99' height=25>")
Dim id,i
For i=0 to rsDate.Fields.Count-1 '设置表头
Response.Write("<td align='center'><font style='font-size:13px;'><b>"&rsDate.Fields(i).Name&"</b></font></td>")
Next
Response.Write("</tr>")
id=0
While not rsDate.EOF and id<dateNum
id=id+1
If id Mod 2=0 then
Response.Write("<tr bgcolor=#f7f6e7>")
Else
Response.Write("<tr bgcolor=#ffffff>")
End If

For Each fils in rsDate.Fields

Response.Write("<td align='center' height=20>"&fils&"</td>")

Next
Response.Write("</tr>")
rsDate.MoveNext
Wend
Response.Write("<tr height=25 bgcolor='#ffdf99'>")
For i=0 to rsDate.Fields.Count-1 '设置表尾
Response.Write("<td align='center'><font style='font-size:13px;'><b>"&rsDate.Fields(i).Name&"</b></font></td>")
Next
Response.Write("</tr>")
Response.Write("</table></td></tr>")

Response.Write("<tr><td height=30 align=left><font stly='font-size:12px;'>(第"&recordHead&"-"&recordLast&"条,共"&rsDate.Recordcount&"条,每页显示"&dateNum&"条)</font></td>")
Response.Write("<form name='formPage1' method='post' action="&URL&"><td height=30 align=right>" & allWrite & "</td></form></tr></table>")
End IF
rsDate.close
Set rsDate=nothing
End Function
%>
---------------------
yp.asp
--------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<%
    province=request("mainmenu")
    city=request("submenu")
    leibie=request("leibie")
    schoolname=request("schoolname")
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>教育黄页</title>
<style type="text/css">
<!--
body {
    background-image: url();
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
body,td,th {
    font-size: 12px;
}
.STYLE1 {font-size: 12px}
.STYLE3 {color: #003366}
.STYLE6 {color: #993300}
tr {
    background-repeat: repeat-x;
}
.STYLE7 {color: #FFFFFF}
.STYLE8 {color: #FF0000}
-->
</style>
</head>

<body>
<table width="1024" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td> <table width="77%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="689"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/top1.jpg" width="187" height="78" /><img src="images/top2.jpg" width="500" height="78" /></td>
          </tr>
         
        </table></td>
        <td width="99"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><div align="center"><img src="images/23.gif" width="16" height="16" /></div></td>
            <td>设为首页</td>
          </tr>
          <tr>
            <td><div align="center"><img src="images/18.gif" width="16" height="16" /></div></td>
            <td>加入收藏</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="30" colspan="2" background="images/line.gif">  <span class="STYLE7">首页</span> | <span class="STYLE7">教育新闻</span> | <span class="STYLE7">益学网视</span> | <span class="STYLE7">益学网赛</span> | <span class="STYLE7">校园网刊</span> | <span class="STYLE7">奖励中心</span> | <span class="STYLE7">帐号管理</span> | <span class="STYLE8">教育黄页</span> | <span class="STYLE7">教育公社</span> | <span class="STYLE7">益智游戏</span> </td>
      </tr>
      <tr>
        <td height="102" colspan="2"><table border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="187" height="102" align="right" valign="top" background="images/tu1.gif"><br />
              <span class="STYLE3">地区搜索:</span><br /></td>
            <td width="500" valign="top" background="images/tu2.gif"><br />
              <br />
               <span class="STYLE6">北京 上海 江苏 浙江 广东 河北 河南 湖北 安徽 湖南 香港 天津 四川 重庆 吉林 辽宁 <br />
               <br />
               青海
              宁夏 新疆 云南 广西 内蒙古 海南 江西 福建 贵州 西藏 山东 甘肃 山西 陕西 台湾 <br />
              <br />
              黑龙江 </span></td>
            <td width="81" valign="top" background="images/tu3.gif"><br />
              <br /></td>
          </tr>
         
        </table></td>
        </tr>
      <tr>
        <td colspan="2" background="images/dot_line.gif"><img name="" src="" width="32" height="1" alt="" /></td>
      </tr>
      <tr>
        <td height="23" colspan="2" background="images/line2.gif">
          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr >  
          <!--#include file="search.asp"-->

          </tr>
        </table>
       </td>
      </tr>

<tr> <td colspan='2'>
<table width=100% height=28 border='0' cellpadding='0' cellspacing='0'>
<tr><td width='15' ><img src='images/arrow.gif' width='11' height='14'/></td>
<td>首页
<% set rs5=server.CreateObject("adodb.recordset")
    sql5="select * from areamain where province_ID="&province
    rs5.open sql5,conn,1,1
    set rs6=server.CreateObject("adodb.recordset")
    sql6="select * from areasub where city_ID="&city
    rs6.open sql6,conn,1,1
    set rs7=server.CreateObject("adodb.recordset")
    sql7="select * from leibie where leibie_ID="&leibie
    rs7.open sql7,conn,1,1
  %>
<% if (not isempty(province)) then %>
<span class='STYLE1'>>>> <%=rs5("name")%></span>
<%end if%>
<% if (not isempty(city)) then%>
<span class='STYLE1'>>>> <%=rs6("name")%></span>
<%end if%>
<%if (not isempty(leibie)) then%>
<span class='STYLE1'>>>> <%=rs7("name")%></span>
<% end if%>
<span class='STYLE1'>>>> <%=schoolname%></span>

</td></tr></table></td></tr>

      <tr>
        <td colspan="2">
<%
if not isempty(province) and not isempty(city) and isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"order by 编号 asc "
end if
if not isempty(province) and not isempty(city) and not isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"and leibie_ID="&leibie &"order by 编号 asc "
end if        
if not isempty(province) and not isempty(city) and not isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"and leibie_ID="&leibie &"and 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if
if isempty(province) and isempty(city) and not isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where leibie_ID="&leibie &"and 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if
if isempty(province) and isempty(city) and isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if
if isempty(province) and isempty(city) and isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school order by 编号 asc "
end if
if isempty(province) and isempty(city) and not isempty(leibie) and isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where leibie_ID="&leibie &"order by 编号 asc "
end if
if not isempty(province) and not isempty(city) and isempty(leibie) and not isempty(schoolname) then
sql="select 编号,学校名称,邮政编码,学校地址,电话号码 from school where province_ID="&province &"and city_ID="&city &"and 学校名称 like '%"&schoolname&"%' order by 编号 asc "
end if   
%>
<%
    page=request("page")
    url="yp.asp"
    call cutPage(sql,conn,"19",page,url)
%>
<!--#include file="function.asp"-->
</td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>
回复

使用道具 举报

发表于 2009-12-26 22:11:57 | 显示全部楼层 IP:江苏扬州
我把源代码给你,帮我看一下怎么改好吗?
回复

使用道具 举报

发表于 2009-12-26 22:12:02 | 显示全部楼层 IP:江苏扬州
分页控件判断嘛...如果是你传递的信息就执行哪个分页数据绑定...
回复

使用道具 举报

发表于 2009-12-26 22:12:07 | 显示全部楼层 IP:江苏扬州
搜索传递参数...通过参数分页.........
回复

使用道具 举报

发表于 2009-12-26 22:12:12 | 显示全部楼层 IP:江苏扬州
asp中怎么进行分页控件判断啊?请多多指教!!
回复

使用道具 举报

发表于 2009-12-26 22:12:17 | 显示全部楼层 IP:江苏扬州
是在上一页\下一页的部分加上参数就可以了吗?
我的网页现在的问题是点击上一页\下一页的时候就会从头开始执行,
相当于搜索时的参数为开始时的参数,是空的,所以总是显示全部的信息.
回复

使用道具 举报

发表于 2009-12-26 22:12:22 | 显示全部楼层 IP:江苏扬州
些个方法..判断参数就可以了...
回复

使用道具 举报

发表于 2009-12-26 22:12:27 | 显示全部楼层 IP:江苏扬州
在搜索的时候分页中没有传递搜索参数
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 23:23 , Processed in 0.393944 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表