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="¤tPage-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'>"¤tPage&"</font><font class='contents'>/"&n&"页</font> "
Response.Write "<font class='contents'> 共查询到"&totalnumber&"种商品 "
Response.Write "<font class='contents'>转到:</font><input CLASS='wenbenkuang' type='text' name='page' size=2 maxlength=8 class=smallInput value="¤tpage&">"
Response.Write " <input type='submit' CLASS='go-wenbenkuang' class='contents' value='GO' name='cndok'></form>"
End Function%>
<%
sub sss() '增加搜索关健字到数据库
if request.Cookies("soeee")("username")<>"" then
set rs_s=server.CreateObject("adodb.recordset")
rs_s.open "select * from [user] where username='"&request.Cookies("soeee")("username")&"'",conn,1,1
t_userid=rs_s("userid")
rs_s.close
set rs_s=server.CreateObject("adodb.recordset")
rs_s.open "select * from shop_his where username='"&request.Cookies("soeee")("username")&"' and bookname='"&s_bookname&"' and lx=2",conn,1,3
if rs_s.recordcount>0 then
rs_s("ltime")=now()
rs_s("userid")=t_userid
rs_s("searchkey")=sql2
rs_s.update
rs_s.close
set rs_s=nothing
else
rs_s.close
set rs_s=server.createobject("adodb.recordset")
rs_s.open "select * from shop_his where username='"&request.Cookies("soeee")("username")&"' and lx=2",conn,1,3
if rs_s.recordcount>=20 then
rs_s.delete
rs_s.update
end if
rs_s.addnew
rs_s("username")=request.Cookies("soeee")("username")
rs_s("searchkey")=sql2
rs_s("bookname")=s_bookname
rs_s("userid")=t_userid
rs_s("lx")=2
rs_s("ltime")=now()
rs_s.update
rs_s.close
set rs_s=nothing
end if
end if
end sub%> </TD>
</TR>
</TABLE></TD>
</TR>
</TABLE>
<TABLE style="BORDER-TOP: #ffcc66 3px solid; FONT-SIZE: 12px" height=18
cellSpacing=0 cellPadding=0 width=988 align=center border=0>
<TBODY>
<FORM name=buttomsearch1 action="result.asp" method=post>
<TR>
<TD vAlign=top align=center bgColor=#ffcc66> <IMG height=22 src="images111/body/img_bottom_search.gif" width=20 align=absMiddle>商品搜索
<SELECT name="select" id="select">
<OPTION VALUE="0" >所有类别</OPTION>
<OPTION VALUE="1" SELECTED>书名</OPTION>
<OPTION VALUE="2">作者</OPTION>
<OPTION VALUE="3">出版社</OPTION>
<OPTION VALUE="4">ISBN</OPTION>
</SELECT>
<INPUT name=searchkey2 id=searchkey2 size=15>
<INPUT type=image height=18 alt=查询 width=27 src="images111/body/img_btn__search_fhb.gif" align=middle border=0 name=image222></TD>
</TR>
</FORM>
else '//高级查讯
sql2="searchkey="&searchkey&"&anclassid="&anclassid&"&jiage="&jiage&"&action="&action&"&selectname="&selectname
if anclassid<>0 then '//判断查讯分类,分类不为空。
select case action
case "0"
sql1=" bookname like '%"&searchkey&"%' or pingpai like '%"&searchkey&"%' or bookcontent like '%"&searchkey&"%' or zz like '%"&searchkey&"%' or isbn like '%"&searchkey&"%'"
case "1"
sql1=" bookname like '%"&searchkey&"%' and (shichangjia<"&jiage&" or huiyuanjia<"&jiage&" or vipjia<"&jiage&") and anclassid="&anclassid&" "
case "2"
sql1=" pingpai like '%"&selectname&"%' and (shichangjia<"&jiage&" or huiyuanjia<"&jiage&" or vipjia<"&jiage&") and anclassid="&anclassid&" "
case "3"
sql1=" bookcontent like '%"&selectname&"%' and (shichangjia<"&jiage&" or huiyuanjia<"&jiage&" or vipjia<"&jiage&") and anclassid="&anclassid&" "
end select
else '//分类为空。
select case action
case "1"
sql1=" bookname like '%"&searchkey&"%' and (shichangjia<"&jiage&" or huiyuanjia<"&jiage&" or vipjia<"&jiage&") "
case "2"
sql1=" pingpai like '%"&selectname&"%' and (shichangjia<"&jiage&" or huiyuanjia<"&jiage&" or vipjia<"&jiage&") "
case "3"
sql1=" bookcontent like '%"&selectname&"%' and (shichangjia<"&jiage&" or huiyuanjia<"&jiage&" or vipjia<"&jiage&") "
end select
end if
end if
call sss()
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_books where "&sql1&" order by adddate desc",conn,1,1
if rs.eof And rs.bof then%>
<TABLE width="760" height="160" border="0" cellpadding="0" cellspacing="0">
<TR>
<TD width="473" rowspan="2" class="neip1"><DIV align="center"><STRONG><BR>
未找到相关结果,可能您要的商品已经售空!<BR>
<BR>
建议您: 检查输入文字和选择的类别是否错误,或换用更少的文字查询。-->></STRONG></DIV></TD>
<TD width="303" height="21" class="neip1"> </TD>
</TR>
<TR>
<TD height="76" class="pt12b style1" onClick="MM_openBrWindow('yuding.asp','预订图书','scrollbars=yes,width=500,height=500')"><A href="#">预订图书</A></TD>
</TR>
</TABLE>
<%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,"result.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"result.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"result.asp"
end if
end if
end if
sub showContent
dim i
i=0
%>
<%do while not rs.eof%>
<TABLE width="790" class="table-xia" border="0" cellspacing="0" cellpadding="0" align="center">
<TR>
<TD width="20%" rowspan="5" class="table-you"><TABLE align=center cellspacing=0 cellpadding=0 width=100 border=0>
<TBODY>
<TR>
<TD align=center>
<%if rs("bookpic")="" then
response.write "<div align=center><a href=showbook_detail.asp?id="&rs("bookid")&" ><img src=images/emptybook.gif width=80 height=110 border=0 style='border:1px solid #EEEEEE'></a></div>"
else%>
<A href=showbook_detail.asp?id=<%=rs("bookid")%> ><IMG src="<%=trim(rs("bookpic"))%>" width=80 border=0 height="110" style='border:1px solid #EEEEEE'></A>
<%end if%>
</TD>
</TR>
</TBODY>
</TABLE></TD>
<TD width="54%" height="28"> <SPAN class="12_b">
<%
set rs_shjia=server.createobject("adodb.recordset")
rs_shjia.open "select * from shjia where username='"&rs("shjianame")&"'",conn,1,1
if rs_shjia.recordcount<>"0" then
response.write "[ <a href=user/index.asp?id="&rs_shjia("shjiaid")&" ><font color=blue>"
response.write trim(rs_shjia("name"))
response.write "</font></a> ]"
end if
rs_shjia.close
set rs_shjia=nothing
response.write "<a href=showbook_detail.asp?id="&rs("bookid")&" >"
if len(trim(rs("bookname")))>30 then
response.write left(trim(rs("bookname")),30)&".."
else
response.write trim(rs("bookname"))
end if
response.write "</a>"
%>
</SPAN></TD>
<TD width="26%" rowspan="5"><TABLE width="90" height="111" border="0" align="center" cellpadding="0" cellspacing="0">
<TR>
<TD height="67" align=left class="pt12"> 市场价: <S><%=rs("shichangjia")&"元"%></S><BR>
会员价:
<%if request.cookies("soeee")("reglx")=2 then %>
<%="<S>"&"<font color=#333333>"&rs("huiyuanjia")&"元</font>"&"</s>"%>
<%else%>
<%="<font color=#FF0000>"&rs("huiyuanjia")&"元</font>"%>
<%end if%>
<BR>
ISBN:<%=rs("isbn1")%></TD>
</TR>
<TR>
<TD align=center>
<%if request.cookies("soeee")("reglx")=2 then %>
<A href="cart.asp?id=<%=rs("bookid")%>&action=add"><IMG src="images/buy1.jpg" width="75" height="21" border=0 align="left"></A>
<%else%>
<A href="cart.asp?id=<%=rs("bookid")%>&action=add"><IMG src="images/buy1.jpg" width="75" height="21" border=0 align="left"></A>
<%end if%>
</TD>
</TR>
</TABLE></TD>
</TR>
<TR>
<TD height="20" valign="top">作者:
<%response.write trim(rs("isbn"))%></TD></TR>
<TR>
<TD height="20" valign="top">出版社:
<%response.write trim(rs("pingpai"))%></TD></TR>
<TR>
<TD height="20" valign="top">出版日期:
<%response.write trim(rs("yssj"))%></TD></TR>
<TR>
<TD valign="top"><FONT color="#000000"><SPAN class="pt12">
<%if len(trim(rs("bookcontent")))>150 then
response.write left(trim(rs("bookcontent")),120)&"..."
else
response.write trim(rs("bookcontent"))
end if%>
</SPAN></FONT></TD>
</TR>
</TABLE>
<HR width="95%" color=#cccccc size="1">
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
<%
End Sub
if jiage="" then '//普通查询
sql2="searchkey="&searchkey&"&anclassid="&anclassid
select case request("anclassid")
case "0"
sql1=" bookname like '%"&searchkey&"%' or pingpai like '%"&searchkey&"%' or bookcontent like '%"&searchkey&"%' or zz like '%"&searchkey&"%' or isbn like '%"&searchkey&"%'"
case "1"
sql1=" bookname like '%"&searchkey&"%'"
case "2"
sql1=" isbn like '%"&searchkey&"%' "
case "3"
sql1=" pingpai like '%"&searchkey&"%' "
case "4"
sql1=" isbn1 like '%"&searchkey&"%' "
case else
sql1=" bookname like '%"&searchkey&"%' or pingpai like '%"&searchkey&"%' or bookcontent like '%"&searchkey&"%' or zz like '%"&searchkey&"%' or isbn like '%"&searchkey&"%'"
end select