<!--#include file="conn.asp"-->
<!--#include file="webconfig.asp"-->
<%dim action,searchkey,anclassid,jiage
anclassid=request("anclassid")
jiage=request("jiage")
action=request.QueryString("action")
searchkey=request.QueryString("searchkey")
if anclassid="" then anclassid=request.QueryString("anclassid")
if jiage="" then jiage=request.QueryString("jiage")
if action="" then action=int(request("action"))
if searchkey="" then searchkey=trim(request("searchkey"))%>
<%call sss()%>
<html>
<head>
<title><%=webname%>--商品搜索结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" rel="stylesheet" type="text/css">
<style>
td{font-size:9pt;line-height:120%;color:#353535} 
body{font-size:9pt;line-height:120%} 

a:link          { color: #000000; text-decoration: none }
a:visited       { color: #000000; text-decoration: none }
a:active        { color: #000000; text-decoration: none }
a:hover         { color: #336699; text-decoration: none; position: relative; right: 0px; top: 1px }
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onMouseOver="window.status='【<%=webname%>】 <%=weburl%> 如果您喜欢本站,别忘了把本站介绍给您的好友哦！：）';return true">
<!--#include file="webtop.asp"-->
<table width="770" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td> 
      <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
        <tr> 
          <td style="padding-left:6px"> 
            <%if searchkey="" then
	response.write "对不起，请您输入查讯关键字"
	response.End
	else
	response.write "您查讯的关健字是：<font color=red>"&searchkey&"</font>"
	end if%>
          </td>
        </tr>
      </table>
      <%'开始分页
				Const MaxPerPage=22 
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    				if Not isempty(request("page")) then
      				currentPage=Cint(request("page"))
   				else
      				currentPage=1
   				end if 
				
set rs=server.CreateObject("adodb.recordset")
if jiage="" then  '//普通查询
select case action
case "1"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookname like '%"&searchkey&"%' ",conn,1,1
case "2"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookzz like '%"&searchkey&"%' ",conn,1,1
case "3"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookchuban like '%"&searchkey&"%' ",conn,1,1
case "4"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,isbn,bookdate from shop_books where isbn='"&searchkey&"' ",conn,1,1
end select
else
'//高级查讯
if anclassid<>0 then  '//判断查讯分类,分类不为空。  
select case action
case "1"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookname like '%"&searchkey&"%' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
case "2"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookzz like '%"&searchkey&"%' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
case "3"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookchuban like '%"&searchkey&"%' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
case "4"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,isbn,bookdate from shop_books where isbn='"&searchkey&"' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
end select
else
'//分类为空。
select case action
case "1"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookname like '%"&searchkey&"%' and huiyuanjia<"&jiage,conn,1,1
case "2"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookzz like '%"&searchkey&"%' and huiyuanjia<"&jiage,conn,1,1
case "3"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,bookdate from shop_books where bookchuban like '%"&searchkey&"%' and huiyuanjia<"&jiage,conn,1,1
case "4"
rs.open "select bookid,bookname,bookzz,bookchuban,shichangjia,huiyuanjia,dazhe,isbn,bookdate from shop_books where isbn='"&searchkey&"' and huiyuanjia<"&jiage,conn,1,1
end select
end if
end if


		  
				if err.number<>0 then
				response.write "数据库中无数据"
				end if
				
  				if rs.eof And rs.bof then
       				Response.Write "<p align='center' > 对不起，没有查讯到您需要的商品！</p>"
   				else
	  				totalPut=rs.recordcount

      				if currentpage<1 then
          				currentpage=1
      				end if

      				if (currentpage-1)*MaxPerPage>totalput then
	   					if (totalPut mod MaxPerPage)=0 then
	     					currentpage= totalPut \ MaxPerPage
	   					else
	      					currentpage= totalPut \ MaxPerPage + 1
	   					end if
      				end if

       				if currentPage=1 then
            			showContent
            			showpage totalput,MaxPerPage,"research.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookmark
            				bookmark=rs.bookmark
            				showContent
             				showpage totalput,MaxPerPage,"research.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"research.asp"
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i
	   			i=0

			%>
      <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#A4C3E6">
        <tr> 
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF">商品名称</font></div>
          </td>
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF">商品厂商</font></div>
          </td>
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF">商品简介</font></div>
          </td>
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF">商品日期</font></div>
          </td>
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF">市场价</font></div>
          </td>
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF">折 扣</font></div>
          </td>
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF">会员价</font></div>
          </td>
          <td bgcolor="#5F95D3"> 
            <div align="center"><font color="#FFFFFF"></font></div>
          </td>
        </tr>
        <%do while not rs.eof%>
        <tr> 
          <%Dim num1 '//判断数字奇偶
num1 = Num1+1
If num1 Mod 2 = 0 Then%>
          <td bgcolor="#FFFFFF" style="padding-left:6px"> 
            <%response.write "<a href=book.asp?id="&trim(rs("bookid"))&" target=_blank>"&trim(rs("bookname"))&"</a>"%>
          </td>
          <td bgcolor="#FFFFFF"> 
            <div align="center"><%=trim(rs("bookzz"))%></div>
          </td>
          <td bgcolor="#FFFFFF"> 
            <div align="center"><%=trim(rs("bookchuban"))%></div>
          </td>
          <td bgcolor="#FFFFFF"> 
            <div align="center"><%=trim(rs("bookdate"))%></div>
          </td>
          <td bgcolor="#FFFFFF"> 
            <div align="center"><%=formatnumber(rs("shichangjia"),2)&"元"%></div>
          </td>
          <td bgcolor="#FFFFFF"> 
            <div align="center"><%="<font color=#FF6600>"&formatnumber(rs("dazhe")*100,2)&"%</font>"%></div>
          </td>
          <td bgcolor="#FFFFFF"> 
            <div align="center"><%="<font color=#FF6600>"&formatnumber(rs("huiyuanjia"),2)&"元</font>"%></div>
          </td>
          <td bgcolor="#FFFFFF"> 
            <div align="center"> 
              <%response.write "<a href=# onClick=""javascript:window.open('shopping.asp?id="&rs("bookid")&"','','width=632,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;""><img src=images/cartd.gif width=60 height=18 border=0></a>"%>
            </div>
          </td>
          <%else%>
          <td bgcolor="#F7FBFF" style="padding-left:6px"> 
            <%response.write "<a href=book.asp?id="&trim(rs("bookid"))&" target=_blank>"&trim(rs("bookname"))&"</a>"%>
          </td>
          <td bgcolor="#F7FBFF"> 
            <div align="center"><%=trim(rs("bookzz"))%></div>
          </td>
          <td bgcolor="#F7FBFF"> 
            <div align="center"><%=trim(rs("bookchuban"))%></div>
          </td>
          <td bgcolor="#F7FBFF"> 
            <div align="center"><%=trim(rs("bookdate"))%></div>
          </td>
          <td bgcolor="#F7FBFF"> 
            <div align="center"><%=formatnumber(rs("shichangjia"),2)&"元"%></div>
          </td>
          <td bgcolor="#F7FBFF"> 
            <div align="center"><%="<font color=#FF6600>"&formatnumber(rs("dazhe")*100,2)&"%</font>"%></div>
          </td>
          <td bgcolor="#F7FBFF"> 
            <div align="center"><%="<font color=#FF6600>"&formatnumber(rs("huiyuanjia"),2)&"元</font>"%></div>
          </td>
          <td bgcolor="#F7FBFF"> 
            <div align="center"> 
              <%response.write "<a href=# onClick=""javascript:window.open('shopping.asp?id="&rs("bookid")&"','','width=632,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;""><img src=images/cartd.gif width=60 height=18 border=0></a>"%>
            </div>
          </td>
          <%end if%>
        </tr>
        <%i=i+1
		if i>=MaxPerPage then Exit Do
		rs.movenext
  loop
  rs.close
  set rs=nothing%>
      </table>
      <%  
				End Sub   
  
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If
				
				Response.Write "<form method=Post action="&filename&"?searchkey="&searchkey&"&action="&action&"&anclassid="&anclassid&"&jiage="&jiage&">"  
				Response.Write "<p align='center' class='contents'> "  
				If CurrentPage<2 Then  
					Response.Write "<font class='contents'>首页 上一页</font> "  
				Else  
					Response.Write "<a href="&filename&"?page=1&searchkey="&searchkey&"&action="&action&"&anclassid="&anclassid&"&jiage="&jiage&" class='contents'>首页</a> "  
					Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&searchkey="&searchkey&"&action="&action&"&anclassid="&anclassid&"&jiage="&jiage&" class='contents'>上一页</a> "  
				End If
				
				If n-currentpage<1 Then  
					Response.Write "<font class='contents'>下一页 尾页</font>"  
				Else  
					Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&searchkey="&searchkey&"&action="&action&"&anclassid="&anclassid&"&jiage="&jiage&" class='contents'>"  
					Response.Write "下一页</a> <a href="&filename&"?page="&n&"&searchkey="&searchkey&"&action="&action&"&anclassid="&anclassid&"&jiage="&jiage&" class='contents'>尾页</a>"  
				End If  
					Response.Write "<font class='contents'> 页次：</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "  
					Response.Write "<font class='contents'> 共查讯到"&totalnumber&"种商品 " 
					Response.Write "<font class='contents'>转到：</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">"  
					Response.Write "&nbsp;<input type='submit'  class='contents' value='GO' name='cndok'></form>"  
				End Function  
			%>
      <%
sub sss() '增加搜索关健字到数据库
if action="1" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_keyname where keyname='"&searchkey&"' ",conn,1,3
if rs.eof and rs.bof then
rs.close
rs.open "select * from shop_keyname",conn,1,3
rs.addnew
rs("keyname")=searchkey
rs("keycount")=1
rs.update
rs.close
set rs=nothing
else
rs("keycount")=rs("keycount")+1
rs.update
rs.close
set rs=nothing
end if
end if
end sub%>
    </td>
  </tr>
</table>
<!--#include file="service.asp"-->
<!--#include file="copyright.asp"-->
</body>
</html>
