| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 594 人关注过本帖
标题:特请yms123老师帮我解决一个小问题[分不多啦,只有68分,全部加给您!]
只看楼主 加入收藏
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
结帖率:87.5%
收藏
已结贴  问题点数:68 回复次数:5 
特请yms123老师帮我解决一个小问题[分不多啦,只有68分,全部加给您!]
yms123老师,您好!刚好看到您回复给“模糊查询用到程序里该怎么做啊?”这个帖子,下载了里面您上传的文件,测试了一下,成功!这正是我所需要的,非常地高兴!谢谢您!我想请您再帮学生一下,就是:1.如何把“搜索框”和“搜索结果显示页面”分开?我想这样做,就是把“搜索框”插入到网页中,点击“搜索”后转到“显示页面”,显示查询结果,如果无查询结果,在显示页面中提示“没有查询到您所要的信息”。请您帮帮我,好吗?多谢!2.我的网站中有多个数据库,用这个程序能否实现同时查询多个数据库的数据啊?不胜感激!


搜索更多相关主题的帖子: 老师 加给 
2009-09-11 22:38
tepnidh
Rank: 2
等 级:论坛游民
帖 子:192
专家分:24
注 册:2009-8-2
收藏
得分:0 
yms老师,帮帮我,好吗?
2009-09-12 23:06
无诲今生
Rank: 8Rank: 8
来 自:桂林理工大学
等 级:蝙蝠侠
威 望:2
帖 子:373
专家分:726
注 册:2009-5-11
收藏
得分:68 
我给一个你吧!
你修改一下就可以用了
<%
const maxrecord=20
currentpage=request("currentpage")
if currentpage<=0 then
currentpage=1
end if
keys=request.form("keys")
 
if keys="" then
keys=request("keys")
end if
 
page=request.form("page")
allpage=request("allpage")
 
if IsNumeric(page) and page<>"" then
   if CLng(page)<=CLng(allpage) and CLng(page)>=1 then
        currentpage=page
    end if
end if
 
types=request.form("types")
 
if types="" then
types=request("types")
end if
 
Function autokey(strkey)
const lngSubKey=2
dim lngLenkey,strNew1,i,strSubKey
if instr(strKey,"=")<>0 or instr(strKey,"'")<>0 or instr(strKey," ")<>0 or instr(strKey,"  ")<>0 or instr(strKey,chr(34))<>0 or instr(strKey,"\")<>0 or instr(strKey,"<")<>0 or instr(strKey,">")<>0 then
Response.redirect("checkerror.html")
end if
lngLenkey=Len(strKey)
 
Select Case lngLenKey
Case 0
Response.redirect("checkerror.html")
Case 1
strNew1=""  
Case Else
For i=1 To lngLenKey-(lngSubKey-1)  
strSubKey=Mid(strKey,i,lngSubKey)  
strNew1=strNew1&" or maintitle like '%"&strSubKey&"%'"  
Next  
End Select  
autokey="Select * from chattext1 where maintitle like '%"& strKey &"%'"&strNew1   
End Function  
%>
 
<p align="center"><font size="6" color="#9966FF">搜索结果</font></p>
<div align="center">
    <table border="0" width="1000" cellspacing="1" id="table1" height="30">
        <tr>
            <td>
            <p align="right"><a href=context1.asp?tagtmp=all><font color="#FF0000">编程技术</font></a>&nbsp;&nbsp;&nbsp; <a href="right.asp"><font color=red>返回首页</font></a>&nbsp;  
            </font></td>
        </tr>
    </table>
</div>
<hr color="#FF33CC" width="1000">
<div align="center">
<%
         if types="论坛贴子" then
                 sql=autokey(keys)
                 set obj=server.createobject("ADODB.Connection")
                 obj.open"dsn=user;"
                 set rs=server.createobject("ADODB.recordset")
                 rs.open sql,obj,1,1
 
                if not (rs.eof and rs.bof) then
                  rs.PageSize=maxrecord
                  totalpage=rs.PageCount
                  totalrecord=rs.RecordCount
%>
 
                <table border="0" width="1000" color="white">
                  <tr><td align="left">共&nbsp;&nbsp;<%=totalrecord%>&nbsp;&nbsp;个搜索结果&nbsp;&nbsp;&nbsp;&nbsp;总共<font color=red><%=totalpage%></font>页&nbsp;&nbsp;&nbsp;&nbsp;当前为第<font color=red><%=currentpage%></font>页</td></tr>
                </table>
 
    <table border="0" width="1000" cellspacing="1" bgcolor="#C8E3FF" id="table2">
 
                 <tr>
         <td align=center width=250>标题</td><td align=center width=250>类型</td><td align=center width=250>作者</td><td align=center width=250>被回复次数</td>
               </tr>
               <tr>
         <td align=center width=250><hr align=center width=249 color=red></td><td align=center width=250><hr align=center width=249 color=red></td><td align=center width=250><hr align=center width=249 color=red></td><td align=center width=250><hr align=center width=249 color=red></td>
               </tr>
                 
<%
                j=0
                rs.Move (currentpage-1)*maxrecord
                do while (not rs.eof)
                  
                 if rs("tag")="HTML" then tptag="HTML"
                 if rs("tag")="JAVA" then tptag="JAVA"
                 if rs("tag")="C" then tptag="C语言"
                 if rs("tag")="CC" then tptag="C++"
                 if rs("tag")="CCC" then tptag="C#"
                 if rs("tag")="数据库" then tptag="数据库"
                 if rs("tag")="VB" then tptag="VB"
 %>
                <tr>
                <td align=left width=250><a href=dealchecklook.asp?offer=<%=rs("offer")%>&tag=<%=rs("tag")%>&id=<%=rs("ID")%> target="_blank"><%=rs("maintitle")%></a></td>
                 <td align=center width=250><%=tptag%></td>
                 <td align=center width=250><%=rs("offer")%></td>
                 <td align=center width=250><%=rs("number")%></td>
                  </tr>
                 <tr>
         <td align=center width=250><hr align=center width=249></td><td align=center width=250><hr align=center width=249></td><td align=center width=250><hr align=center width=249></td><td align=center width=250><hr align=center width=249></td>
                </tr>
<%
                  j=j+1
                  if j>=maxrecord then exit do
                  rs.MoveNext
                  loop
%>
 
<%
                  else
%>
                      <br><p align=center>没有找到符合关键字的内容</p>
<%         
                 end if
     end if
%>
 
</table>
<hr width=1000 align=center>
<table width=1000 align=center>
<%
if cint(currentpage)<>1 then
%>
<a href=dealfind.asp?currentpage=1&keys=<%=keys%>&types=<%=types%>><font color=red>第一页</font></a>&nbsp;&nbsp;
<%
end if
if cint(currentpage)<>cint(totalpage) then
%>
<a href=dealfind.asp?currentpage=<%=totalpage%>&keys=<%=keys%>&types=<%=types%>><font color=red>最后页</font></a>&nbsp;&nbsp;
<%
end if
if totalrecord<=maxrecord then
%>
上一页&nbsp;&nbsp;下一页
<%
else
     if cint(currentpage)=cint(totalpage) then
        currentpage=cint(currentpage)-1
%>
       <a href=dealfind.asp?currentpage=<%=currentpage%>&keys=<%=keys%>&types=<%=types%>><font color=red>上一页</font color=red></a>&nbsp;&nbsp;下一页
<%
     else
          if currentpage=1 then
             currentpage=currentpage+1
%>
            上一页&nbsp;&nbsp;<a href=dealfind.asp?currentpage=<%=currentpage%>&keys=<%=keys%>&types=<%=types%>><font color=red>下一页</font></a>
<%
          else
             currentpage1=currentpage-1
             currentpage2=currentpage+1
%>
          <a href=dealfind.asp?currentpage=<%=currentpage1%>&keys=<%=keys%>&types=<%=types%>><font color=red>上一页</font></a>&nbsp;&nbsp;<a href=dealfind.asp?currentpage=<%=currentpage2%>&keys=<%=keys%>&types=<%=types%>><font color=red>下一页</font></a>
<%
          end if
     end if
end if
 
%>
</td><td align=right><form action=dealfind.asp?keys=<%=keys%>&allpage=<%=totalpage%>&types=<%=types%>&currentpage=<%=currentpage%> name="go" method="post">
跳到&nbsp;<input type="text" name="page" value="" width="10">&nbsp;页&nbsp;&nbsp;<input type="submit" value="  GO  ">
</form></td></tr>
</table>
</div>
<p align="center"> </p>


因为是从我的网站中复制过来的,所你修改下就可以用了

顺境逆境切莫止境,得意失意切莫在意。
2009-09-12 23:51
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:0 
<form action="地址" .........>
表单内容
</form>
<%
If Not Rs.Eof Then
    显示数据
Else
    Response.Write "没有查询到您所要的信息"
End If
%>
可以查询多个不过一般都是多个表吧~搞多个数据库!!
2009-09-13 08:55
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
搜索框和结果页面是可以分开来写的,如果是使用iframe的话在form表单里加入target="[iframe的名字]"就会在搜索时提交到iframe框里
比如
a.asp
<html>
<body>

<form action="地址" target="abc">
表单内容
</form>
<iframe name="abc" src="b.asp" ></iframe>
</body>
</html>

b.asp
<%
'获得提交的数据显示结果
If Not Rs.Eof Then
    显示数据
Else
    Response.Write "没有查询到您所要的信息"
End If
%>
2009-09-13 13:15
红月
Rank: 2
等 级:论坛游民
帖 子:10
专家分:12
注 册:2009-9-14
收藏
得分:0 
嗯嗯!!又认识了下...不错

没有如果!
2009-09-14 12:06
快速回复:特请yms123老师帮我解决一个小问题[分不多啦,只有68分,全部加给您! ...
数据加载中...
 
   



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

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