<!--#include file="include/nowshop.asp"-->
<!--#include file="top.asp"-->
<html>
<title>商品高级搜索-<%=sitename%>-<%=siteurl%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="description" content="<%=sitedescription%>">
<meta name="keywords" content="<%=sitekeywords%>">
<link rel="stylesheet" href="css.css" type="text/css">
</head>
<%
action=request("action")
if action="" then
%>

<center>
<table width="768" border=0 cellspacing=0 cellpadding=0 align=center bgcolor="#FFFFFF">  
<tr><td align=center valign=top width=178 background=images/left_bg.gif>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
        <TBODY>
          <TR> 
            <TD><IMG height=22 src="list/zbhz_shopping_car.gif" 
            width=180></TD>
          </TR>
          <TR> 
            <TD bgColor=#fcd8e7><IFRAME border=0 name=new_date11 marginWidth=0 
            marginHeight=0 src="gouwuche.asp" frameBorder=0 
            noResize width=178 scrolling=no height=83 spacing="0" 
            vspale="0"></IFRAME></TD>
          </TR>
        </TBODY>
      </TABLE>
			    <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                  <TBODY>
				  <tr><td height=5 bgcolor="#FFFFFF"></td></tr>
                    <TR> 
					
                      <TD background="images/left_bg.gif"><IMG height=20 src="list/pic_fl.gif" 
              width=180>			  </TD>
			  <tr>
			  <td>
<TABLE align=center cellSpacing=0 cellPadding=0 width=175 border=0>
	<tr><td width=175 colspan=3 height=10 ></td></tr>
<%
color1="77CC00"     '分类列表中大类的颜色
color2="0066ff"     '分类列表中中类的颜色
viewmidclass=1      '是否显示中类，1表示显示，0表示不显示
dim larcode(100)    '最多支持100个大类
dim midcode(20)     '最多支持20个中类

	'以下是分类列表，首先读取全部大类，然后根据每个大类读取各自的中类
	response.write "<table width='175' border='0' align='center' cellpadding=1 cellspacing=1>"
	Dim a,b,c
	sqllar="select Distinct LarCode,LarSeq from bclass order by LarSeq"
	Set rsprodtree=Server.CreateObject("ADODB.RecordSet") 
	rsprodtree.Open sqllar,conn,1,1 

	if rsprodtree.bof and rsprodtree.eof then
		response.write "<tr><td width=175 colspan=3 height=100 align=center>对不起，本商城暂未开业</td></tr>"
	else
		
		i=0
		Do While Not rsprodtree.eof	
		i=i+1
		larcode(i)=rsprodtree("LarCode")
		rsprodtree.movenext	
		if rsprodtree.eof then exit do
		Loop
	end if
	set rsprodtree=nothing
	set sqllar=nothing


	
	FOR t=1 to i
	response.write "<tr><td width='175'  class='dfont' height=25 colspan=3 valign=middle><B>&nbsp;&nbsp;&nbsp;&nbsp;<img src=images/dot.gif  border=0>&nbsp;&nbsp;<a href='class.asp?LarCode="&LarCode(t)&"'>"&LarCode(t)&"</B></a></td></tr>"
	response.write "<tr>"

if viewmidclass<>0 then           '是否显示中类
	'以下是根据前面读取的大类名称，读取各个大类下的中类
	sqllar="select MIDCode,MIDSeq from bclass where larcode='"&larcode(t)&"' order by MIDSeq"
	Set rsprodtree=Server.CreateObject("ADODB.RecordSet") 
	rsprodtree.Open sqllar,conn,1,1 
		m=0
		Do While Not rsprodtree.eof	
		m=m+1
		midcode(m)=rsprodtree("midCode")
		rsprodtree.movenext	
		if rsprodtree.eof then exit do
		Loop

	set rsprodtree=nothing
	set sqllar=nothing

		for n=1 to m
		if n mod 2<>0 then
		response.write "<td width=85 align=right  class='dfont'><a href='class.asp?LarCode="&LarCode(t)&"&MidCode="&MidCode(n)&"'>"&MidCode(n)&"</a></TD>"
		else
		response.write "<td align=center width=5>|</td><td  width=85 class='dfont'><a href='class.asp?LarCode="&LarCode(t)&"&MidCode="&MidCode(n)&"'>"&MidCode(n)&"</a></TD></tr><tr>"
	    end if
		next
			response.write "<tr><td width=175 colspan=3 height=10 ></td></tr>"

end if

	next

%>
                                  </table>
 			  </td>
			  </tr>
                    </TR>
                  </TBODY>
                </TABLE>

 
</td>
      <td width=590 align=center valign=top><table>
          <tr> 
            <td align="center" valign="middle"><TABLE cellSpacing=0 cellPadding=0 width=547 border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
                <TBODY>
                  <TR> 
                    <TD bgColor=#f4f5fd height=25><font color="#000000">　<B>商品高级搜索<font color="#FF0000">（</font></B></font><font color=red><b>根据以下一个或多个复合条件搜索商品：</b></font><strong><font color="#FF0000"> 
                      ）</font></strong> </TD>
                  </TR>
                </TBODY>
              </TABLE></td>
          </tr>
          <tr> 
            <td align="center" valign="middle"><table width="547" align=center  style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid"   bordercolor="#333333" cellspacing="0" cellpadding="2">
<form name=search action=search_more.asp method=post>
<tr><td width=25% align=center>根据商品类别</td><td>
<%
	set rs=server.createobject("adodb.recordset") 
	sql="select distinct LarCode,LarSeq from bclass order by LarSeq" 
	rs.Open sql,conn,1,1 
	response.write "<select name='fenlei'>"
	response.write	"<option value='' selected>选择要搜索的商品分类</option>"
	if rs.bof and rs.eof then
	response.write "<option selected value=''>-暂无分类-</option>"
	else
	Do While Not rs.eof	
	response.write "<option value='"&rs("larCode")&"'>"&rs("LarCode")&"</option>"
	rs.movenext
	  if rs.eof then exit do
	loop
	response.write "<option value='未归类'>所有未归类商品</option>"
	end if
	rs.close
	set rs=nothing
%>
</td></tr>
<tr><td width=25% align=center> 根据商品名称
</td><td><input type=text name=name_key size=20 maxlength=20></td></tr>
<td width=25% align=center>根据商品编号
</td><td><input type=text name=id_key size=20 maxlength=20></td></tr>
<td width=25% align=center>根据商品简介
</td><td><input type=text name=jj_key size=20 maxlength=20></td></tr>
<td width=25% align=center>根据商品内容
</td><td><input type=text name=nr_key size=20 maxlength=20></td></tr>
<td width=25% align=center>根据商品价格
</td><td>价格范围：从 <input type=text name=jg1_key size=5 maxlength=4> 元 至 <input type=text name=jg2_key size=5 maxlength=5> 元</td></tr>
<td width=25% align=center>根据是否推荐
</td><td><input type="radio" name="tj_key" value="1">是 <input type="radio" name="tj_key" value="2">否 <input type="radio" name="tj_key" value="3">全部</td></TR>
<td width=25% align=center>根据是否特价
</td><td><input type="radio" name="tej_key" value="1">是 <input type="radio" name="tej_key" value="2">否 <input type="radio" name="tej_key" value="3">全部</td></TR>
<td width=25% align=center>搜索结果排序方式
</td><td><input type="radio" name="paixu" value="1" checked>按上架日期<br><input type="radio" name="paixu" value="2">按上架日期（倒序）<br><input type="radio" name="paixu" value="3">按编号（由大到小）<br><input type="radio" name="paixu" value="4">按编号（由小到大）<br><input type="radio" name="paixu" value="5">按商品名称<br><input type="radio" name="paixu" value="6">按热门程度</td></TR>

<tr align="center"><td colspan=2><INPUT name="action" TYPE="hidden" value="ok"><INPUT name=action TYPE="submit" value="开始搜索"></td></tr>
</form>
</table></td>
          </tr><tr align="center">
            <td colspan=2>&nbsp; </td>
          </tr>
        </table> 
        <p align=left><br>
</TD>
    </TR></TABLE>
<!--#include file="down.asp"-->
</center>
</body>
</html>

<%
else
call buyok_check_path()
'开始搜索
if trim(request("jg1_key"))<>"" then
  if not isNumeric(trim(request("jg1_key"))) then
	response.write "<script language='javascript'>"
	response.write "alert('您填写的内容不符合要求，价格必须是数字，请检查！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
  end if
end if

if trim(request("jg2_key"))<>"" then
  if not isNumeric(trim(request("jg2_key"))) then
	response.write "<script language='javascript'>"
	response.write "alert('您填写的内容不符合要求，价格必须是数字，请检查！');"
	response.write "location.href='javascript:history.go(-1)';"
	response.write "</script>"
	response.end
  end if
end if

	if trim(request("name_key"))<>"" then addsql=addsql+" and prodname like '%"&trim(request("name_key"))&"%'"
	if trim(request("ID_key"))<>"" then addsql=addsql+" and prodID like '%"&trim(request("ID_key"))&"%'"
	if trim(request("jj_key"))<>"" then addsql=addsql+" and ProdDisc like '%"&trim(request("jj_key"))&"%'"
	if trim(request("nr_key"))<>"" then addsql=addsql+" and MemoSpec like '%"&trim(request("nr_key"))&"%'"
	if request("tj_key")="1" then addsql=addsql+" and remark='1'"
	if request("tj_key")="2" then addsql=addsql+" and remark='0'"
	if request("tej_key")="1" then addsql=addsql+" and tejia='1'"
	if request("tej_key")="2" then addsql=addsql+" and tejia='0'"
	if trim(request("fenlei"))<>"" then addsql=addsql+" and larcode='"&trim(request.form("fenlei"))&"'"
	if trim(trim(request("jg1_key")))<>"" then addsql=addsql+" and PriceList>"&trim(request("jg1_key"))
	if trim(trim(request("jg2_key")))<>"" then addsql=addsql+" and PriceList<"&trim(request("jg2_key"))
	if request("paixu")="1" then orderby=" order by adddate desc"
	if request("paixu")="2" then orderby=" order by adddate"
	if request("paixu")="3" then orderby=" order by prodid desc"
	if request("paixu")="4" then orderby=" order by adddate"
	if request("paixu")="5" then orderby=" order by prodname"
	if request("paixu")="6" then orderby=" order by ClickTimes desc"

if addsql="" then
response.cookies("buyok")("search")=""
Response.Redirect("search_more.asp")
else

dim keywords(3)
keywords(1)=request("name_key")
keywords(2)=request("jj_key")
keywords(3)=request("nr_key")

for i=1 to 3
keyword=keywords(i)
if keyword<>"" then 
Set rs=Server.CreateObject("ADODB.RecordSet") 
sql="select * from bkey where keywords='"&keyword&"'"
rs.open sql,conn,1,3
if not (rs.eof and rs.bof) then
rs("num")=rs("num")+1
rs("keydate")=now()
else
rs.addnew
rs("keywords")=keyword
rs("keydate")=now()
end if
rs.update
rs.close
set rs=nothing
end if
next

sql="select * from bproduc where ProdId is not null" + addsql +orderby
response.cookies("buyok")("search")=sql
Response.Redirect("search.asp")
end if

end if

conn.close
set conn=nothing
%>
