| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1070 人关注过本帖
标题:[求助]请问分页与搜索在一个页面中时分页不正常怎么办?
只看楼主 加入收藏
小溪
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-9-7
收藏
 问题点数:0 回复次数:11 
[求助]请问分页与搜索在一个页面中时分页不正常怎么办?
点击分页按钮时就会显示全部信息而不按搜索关键字显示,这该怎么改?
搜索更多相关主题的帖子: 搜索 页面 按钮 关键 
2006-09-07 10:38
hoya
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:538
专家分:0
注 册:2006-6-27
收藏
得分:0 
搜索传递参数...通过参数分页.........

妈的...一天能卖一颗就很不错了...
2006-09-07 10:56
小溪
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-9-7
收藏
得分:0 
我也传递参数了,但还是不行
在首页可以正常实现,接着点击分页就不行了,就会显示全部信息了
2006-09-07 11:06
hoya
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:538
专家分:0
注 册:2006-6-27
收藏
得分:0 
分页控件判断嘛...如果是你传递的信息就执行哪个分页数据绑定...

妈的...一天能卖一颗就很不错了...
2006-09-07 11:52
小溪
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-9-7
收藏
得分:0 
asp中怎么进行分页控件判断啊?请多多指教!!
2006-09-07 12:36
hoya
Rank: 5Rank: 5
等 级:贵宾
威 望:15
帖 子:538
专家分:0
注 册:2006-6-27
收藏
得分:0 
些个方法..判断参数就可以了...

妈的...一天能卖一颗就很不错了...
2006-09-07 13:52
小溪
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-9-7
收藏
得分:0 
我把源代码给你,帮我看一下怎么改好吗?
2006-09-07 14:00
小溪
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-9-7
收藏
得分:0 
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>


2006-09-07 14:07
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
在搜索的时候分页中没有传递搜索参数

http://www./
2006-09-07 16:44
小溪
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2006-9-7
收藏
得分:0 
是在上一页\下一页的部分加上参数就可以了吗?
我的网页现在的问题是点击上一页\下一页的时候就会从头开始执行,
相当于搜索时的参数为开始时的参数,是空的,所以总是显示全部的信息.

2006-09-07 17:14
快速回复:[求助]请问分页与搜索在一个页面中时分页不正常怎么办?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019923 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved