如下代码是一个订单搜索页,前表单传来的订单号判定有则显示详细的信息,无则"提示没有符合您要的信息,请确认订单编号输入是否正确!" 但是不行啊。不管输入的订单号对与错都显示,"提示没有符合您要的信息,请确认订单编号输入是否正确!" 是不是sql="select * from order where shop_id ='%"+shop_id+"%'"写得不对啊?
<% on error resume next
dim shop_id
shop_id=trim(request.form(shop_id))
set rs=server.createobject("adodb.recordset")
sql="select * from order where shop_id ='%"+shop_id+"%'"
rs.open sql,conn,1,1
if rs.eof then
response.write("<script language=javascript>alert('没有符合您要的信息,请确认订单编号输入是否正确!');history.go(-1)</script>")
else
%>
<tr>
<td height="40" align="center"><%=rs("shop_id")%></td>
<td height="40" align="center"><%=rs("name")%></td>
<td height="40" align="center"><%=rs("tel")%></td>
<td height="40" align="center"><%=rs("number")%></td>
<td height="40" align="center"><%=rs("title")%></td>
<td height="40" align="center"><%=rs("mobile")%></td>
<%end if%>
sql="select * from order where shop_id ='%"+shop_id+"%'"
改成
sql="select * from order where shop_id like '%"+shop_id+"%'"
或者改成
sql="select * from order where shop_id ='" & shop_id &"'"
试试
if rs.eof then
response.write("<script language=javascript>alert('没有符合您要的信息,请确认订单编号输入是否正确!');history.go(-1)</script>")
else
do while not rs.eof
%>
<tr>
<td height="40" align="center"><%=rs("shop_id")%></td>
<td height="40" align="center"><%=rs("name")%></td>
<td height="40" align="center"><%=rs("tel")%></td>
<td height="40" align="center"><%=rs("number")%></td>
<td height="40" align="center"><%=rs("title")%></td>
<td height="40" align="center"><%=rs("mobile")%></td>
<%
rs.movenext
loop
end if
rs.close
set rs=nothing
%>