急需网站高手给我解答一下网站中的搜索问题

来源:百度知道 编辑:UC知道 时间:2024/06/10 21:02:52
<!--#include file="Comm/conn.asp" -->
<%
Dim pageurl
pageurl="search.asp"
Page=request("page")
SubLar=request("LarCode")
Keywords=Trim(request("keywords"))

sqlprod="select * from ProdMain where online=true "
if SubLar<>"" then sqlprod = sqlprod + "and LarCode='"&SubLar&"'"
'在型号和名称里面查找
if Keywords<>"" then sqlprod = sqlprod + "and ProdName like '%"&keywords&"%' or Model like '%"&keywords&"%'"
%>
<html><head>
<title>搜索结果-<%=keywords%>-<%=sitename%>-<%=siteurl%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Robots" content="index,follow">
<meta name="Abstract" content="Cyco

Dim pageurl '定义变量
pageurl="search.asp" '定义当前页面的地址
Page=request("page") '获取当前的页数
SubLar=request("LarCode") '看意思应该是获取分类
Keywords=Trim(request("keywords")) '获取用户输入的关键字

sqlprod="select * from ProdMain where online=true " 定义SQL语句
if SubLar<>"" then sqlprod = sqlprod + "and '如果分类不为空,在SQL语句中添加分类为用户设定的条件
LarCode='"&SubLar&"'"
'如果关键字不为空那么在型号和名称里面查找和关键字匹配的内容
if Keywords<>"" then sqlprod = sqlprod + "and ProdName like '%"&keywords&"%' or Model like '%"&keywords&"%'"

只解释ASP语句,其他的HTMl代码自己网上学

sqlprod="select * from ProdMain where online=true "
if SubLar<>"" then sqlprod = sqlprod + "and LarCode='"&SubLar&"'"
if Keywords<>"" then sqlprod = sqlprod + "and ProdNam