| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 567 人关注过本帖
标题:[求助]关于搜索的问题~~
取消只看楼主 加入收藏
蝈蝈
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2005-4-14
收藏
 问题点数:0 回复次数:4 
[求助]关于搜索的问题~~

一个关于搜索的问题~ 搜索栏有5个项目,不填关键字直接搜索其中的任意一个,在不超过一页的时候没有问题,超过一页会出现如下的问题,第一页显示正确,但点下页到第二页时会发现把数据库里所有的东西都调出来了,而不是搜索到的东西了,请高手指教~~ 搜索框的代码: <table width="100%" border="0" cellpadding="0" cellspacing="0"> <form name="FindForm" method="post" action="FindBody.asp"> <tr bgcolor="#FFFFFF"> <td>&nbsp;</td> <td>&nbsp;</td> </tr> <tr bgcolor="#FFFFFF"> <td height="24" align="right">类 别:</td> <td><select name="Sort" class="Button" id="Sort"> <option value="" selected>=请选择=</option> <% Set FRs=Server.CreateObject ("ADODB.Recordset") FindSQL="Select * From Class Order by Class_Num" FRs.Open FindSQL,Dbconn,1,1 Do Until FRs.EOF %> <option value="<%=FRs("CID")%>"><%=FRs("Class_Name")%></option> <% FRs.MoveNext Loop FRs.Close Set FRs=Nothing %> </select></td> </tr> <tr bgcolor="#FFFFFF"> <td height="24" align="right">关键字:</td> <td><INPUT id=KeyWord size=12 name=KeyWord></td> </tr> <tr align="center" bgcolor="#FFFFFF"> <td height="24" colspan="2"><INPUT class=Button id=Find onclick="FindForm.submit()" type=button value="搜 索" name=Find> <INPUT class=Button id=Reset type=reset value="重 置" name=Reset></td> </tr> <tr bgcolor="#FFFFFF"> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </form> </table> FindBody.asp的代码: <%

Const MaxPerPage=9 Dim TotalPut Dim CurrentPage Dim TotalPages Dim CID Dim KeyWord

If Not isempty(Request("Page")) Then CurrentPage=Cint(Request("Page")) Else CurrentPage=1 End if

CID=Request("Sort") KeyWord =Request("KeyWord")

Set Rs=Server.CreateObject ("ADODB.Recordset")

If CID<>"" Then StrSQL="SELECT * FROM Image Where CID="& CID &" and Model like '%" & KeyWord &"%' ORDER BY ID DESC" Else

StrSQL="SELECT * FROM Image ORDER BY ID DESC" End If Rs.Open StrSQL,dbconn,1,1

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 %>

<% Set Ds=Server.CreateObject ("ADODB.Recordset") DsSQL="Select * From Class Order By Class_Num" Ds.Open DsSQL,DbConn,1,1 Do Until Ds.EOF %> <td height="30"><a href="Product.asp?CID=<%=Ds("CID")%>"><%=Ds("Class_Name")%></a></td> <% Ds.MoveNext Loop Ds.Close Set Ds=Nothing %>

<% If CurrentPage=1 Then ShowContent Showpage Totalput,MaxPerPage,"FindBody.asp" Else If (CurrentPage-1)*MaxPerPage<TotalPut Then Rs.move (CurrentPage-1)*MaxPerPage Dim bookmark bookmark=rs.bookmark ShowContent Showpage Totalput,MaxPerPage,"FindBody.asp" Else CurrentPage=1 ShowContent Showpage Totalput,MaxPerPage,"FindBody.asp" End If End If Sub ShowContent Do While Not Rs.EOF '第一格

Response.Write "<tr align='center'>" Response.Write "<td width='33%'>" Response.Write "<table width=160 height=140 border=0 cellpadding=0 cellspacing=1 bgcolor=#CCCCCC><tr>" Response.Write "<td align=center bgcolor=#FFFFFF><img src='Photo/"& Rs("S_Image") &"' onclick=iPop('Photo/"& Rs("D_Image") &"',"& Rs("Width") &","& Rs("Height") &",'平湖市卓树塑料五金厂') style='CURSOR:hand' width=150 height=130></td></tr></table>" Response.Write "<table width=160 border=0 cellspacing=0 cellpadding=0><tr>" Response.Write "<td height=40 align=center>"& Rs("Model") &"</td></tr></table></td>"

i=i+1 If i>=MaxPerPage Then Exit Do rs.MoveNext If Rs.EOF Then

Response.Write "<td width='33%'>" Response.Write "</td>"

Response.Write "<td width='33%'>" Response.Write "</td>" Response.Write "</tr>" Exit Do

End If

'第二格 Response.Write "<td width='33%'>" Response.Write "<table width=160 height=140 border=0 cellpadding=0 cellspacing=1 bgcolor=#CCCCCC><tr>" Response.Write "<td align=center bgcolor=#FFFFFF><img src='Photo/"& Rs("S_Image") &"' onclick=iPop('Photo/"& Rs("D_Image") &"',"& Rs("Width") &","& Rs("Height") &",'平湖市卓树塑料五金厂') style='CURSOR:hand' width=150 height=130></td></tr></table>" Response.Write "<table width=160 border=0 cellspacing=0 cellpadding=0><tr>" Response.Write "<td height=40 align=center>"& Rs("Model") &"</td></tr></table></td>" i=i+1 If i>=MaxPerPage Then Exit Do rs.MoveNext If Rs.EOF Then

Response.Write "<td width='33%'>" Response.Write "</td>" Response.Write "</tr>" Exit Do

End If

'第三格 Response.Write "<td width='33%'>" Response.Write "<table width=160 height=140 border=0 cellpadding=0 cellspacing=1 bgcolor=#CCCCCC><tr>" Response.Write "<td align=center bgcolor=#FFFFFF><img src='Photo/"& Rs("S_Image") &"' onclick=iPop('Photo/"& Rs("D_Image") &"',"& Rs("Width") &","& Rs("Height") &",'平湖市卓树塑料五金厂') style='CURSOR:hand' width=150 height=130></td></tr></table>" Response.Write "<table width=160 border=0 cellspacing=0 cellpadding=0><tr>" Response.Write "<td height=40 align=center>"& Rs("Model") &"</td></tr></table></td></tr>"

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

%> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="30" align="right"><% response.write "<font color=#000000'> 共 <b>"&totalnumber&"</b> 条记录 <b>"&maxperpage&"</b> 条记录/每页</font> " If CurrentPage<2 Then response.write "<font color='#b9b9b9'>首页 上一页</font> " Else response.write "<a href="&Filename&"?Sort="&Sort&"&KeyWord="& KeyWord &"&Page=1 class=green>首页</a> " response.write "<a href="&Filename&"?Sort="&Sort&"&KeyWord="& KeyWord &"&Page="&CurrentPage-1&" class=green>上一页</a> " End If If n-currentpage<1 Then response.write "<font color='#b9b9b9'>下一页 尾页</font>" Else response.write "<a href="&Filename&"?Sort="&Sort&"&KeyWord="& KeyWord &"&Page="&(CurrentPage+1)&" class=green>下一页</a> " response.write "<a href="&Filename&"?Sort="&Sort&"&KeyWord="& KeyWord &"&Page="&n&" class=green>尾页 </a>" End If response.write "<font color=#000000> 当前第 <b>"& Currentpage &"</b> 页</font>&nbsp;" End Function %> 请高手指点,万分感谢~~~

搜索更多相关主题的帖子: 搜索 
2005-06-22 13:26
蝈蝈
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2005-4-14
收藏
得分:0 
高手救救我啊~~

2005-06-22 17:53
蝈蝈
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2005-4-14
收藏
得分:0 
怎么办呢?有没有高手帮帮啊?我才开始学asp啊~真的不懂~~~

楼上的,问题解决了吗??怎么解决的啊??

2005-06-23 10:26
蝈蝈
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2005-4-14
收藏
得分:0 
楼上的大虾,可不可以讲清楚一点呢?我不懂~~下面三个是哪三个?怎么改啊?

2005-06-23 12:36
蝈蝈
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2005-4-14
收藏
得分:0 
救命啊~~大虾来帮忙啊~~

2005-06-23 17:18
快速回复:[求助]关于搜索的问题~~
数据加载中...
 
   



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

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