当前位置: 代码迷 >> ASP >> 关于搜索的有关问题,请各位朋友帮忙下
  详细解决方案

关于搜索的有关问题,请各位朋友帮忙下

热度:244   发布时间:2012-02-07 17:45:36.0
关于搜索的问题,请各位朋友帮忙下
search.asp代码
<!--#include   file= "conn.asp "-->
<%
id=request( "id ")
  if   trim(request( "keyword ")) <> " "   then   '获得搜索关键词
kword=trim(request( "keyword "))
sql= "select   name,id,time,part   from   works   where   name   like   '% "&kword& "% '   or   time   like   '% "&kword& "% '   or   part   like   '% "&kword& "% '   order   by   id   desc "   '按照ID字段倒序排列
else
sql= "select   name,id,time,part   from   works   order   by   id   desc "
end   if
set   rs=server.CreateObject( "Adodb.recordset ")
'response.write   sql
rs.open   sql,conn,1,3   %>
搜索结果 <a   href= "see.asp?id= <%=rs( "id ")%> "   target= "_blank "> <%=rs( "name ")%> </a>

see.asp代码
<!--#include   file= "conn.asp "-->
<%  
id=request( "id ")
set   rs=server.CreateObject( "adodb.recordset ")
sql= "select   *   from   works     order   by   id   desc "
rs.open   sql,conn,1,3
%>
其他代码就是显示字段内容的,就不必给出来了把
现在的问题我比如搜索:张三
点搜索结果 <a   href= "see.asp?id=3 "   target= "_blank "> 张三 </a>
打开却是李四的
请各位朋友帮忙
谢谢



------解决方案--------------------
see.asp代码
<!--#include file= "conn.asp "-->
<%
id=request( "id ")
set rs=server.CreateObject( "adodb.recordset ")
sql= "select * from works Where ID= "&ID
rs.open sql,conn,1,3
%>