当前位置: 代码迷 >> ASP >> 不提交表单就出现查询结果的奇怪有关问题
  详细解决方案

不提交表单就出现查询结果的奇怪有关问题

热度:248   发布时间:2012-02-07 17:45:36.0
不提交表单就出现查询结果的奇怪问题。
小弟初学asp,做了个查询表单,使用三个查询条件,为实现模糊,代码如下:
<%
dim   rs3
dim   sql3

set   rs3=server.createobject( "adodb.recordset ")
sql3   =   "select   *   from   ziliao   "
rs3.open   sql3,MM_conn_STRING,1,1
%>
<%
dim   timeid
dim   placeid
dim   name
timeid=request.QueryString( "timeid ")
palceid=request.QueryString( "placeid ")
name=request.QueryString( "name ")
%>
<%
if   trim(timeid)= " "   and   trim(placeid)= " "   and   trim(name)= " "   then
          sql= "select   *   from   ziliao   "
    end   if
    if   trim(timeid)= " "   and   trim(placeid)= " "   and   trim(name) <> " "   then
          sql= "select   *   from   ziliao   where   name   like   '% "&trim(name)& "% '   "
    end   if
    if   trim(timeid)= " "   and   trim(placeid) <> " "   and   trim(name)= " "   then
          sql= "select   *   from   ziliao   where   placeid   like   '% "&trim(placeid)& "% '   "
    end   if
    if   trim(timeid)= " "   and   trim(placeid) <> " "   and   trim(name) <> " "   then
          sql= "select   *   from   ziliao   where   placeid   like   '% "&trim(placeid)& "% '   and   name   like   '% "&trim(name)& "% '   "
    end   if
    if   trim(timeid) <> " "   and   trim(placeid)= " "   and   trim(name)= " "   then
          sql= "select   *   from   ziliao   where   timeid   like   '% "&trim(placeid)& "% '   "
    end   if
    if   trim(timeid) <> " "   and   trim(placeid)= " "   and   trim(name) <> " "   then
          sql= "select   *   from   ziliao   where   timeid   like   '% "&trim(timeid)& "% '   and   name   like   '% "&trim(name)& "% '   "
    end   if
    if   trim(timeid) <> " "   and   trim(placeid) <> " "   and   trim(name)= " "   then
          sql= "select   *   from   ziliao   where   timeid   like   '% "&trim(timeid)& "% '   and   placeid   like   '% "&trim(placeid)& "% '   "
    end   if
    if   trim(timeid) <> " "   and   trim(placeid) <> " "   and   trim(name) <> " "   then
          sql= "select   *   from   ziliao   where   timeid   like   '% "&trim(timeid)& "% '   and   placeid   like   '% "&trim(placeid)& "% '   and   name   like   '% "&trim(name)& "% '   "
  相关解决方案