📄 research.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="webtop.asp"-->
<%dim action,searchkey,anclassid,jiage,searchclass
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"))%>
<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">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onMouseOver="window.status='【<%=webname%>】 <%=weburl%> 如果您喜欢本站,别忘了把本站介绍给您的好友哦!:)';return true">
<%'开始分页
Const MaxPerPage=15
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"
searchclass="书名"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookname like '%"&searchkey&"%' ",conn,1,1
case "2"
searchclass="作者"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookzz like '%"&searchkey&"%' ",conn,1,1
case "3"
searchclass="出版社"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookchuban like '%"&searchkey&"%' ",conn,1,1
case "4"
searchclass="ISBN"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,isbn,bookdate,adddate from shop_books where isbn='"&searchkey&"' ",conn,1,1
end select
else
'//高级查询
if anclassid<>0 then '//判断查询分类,分类不为空。
select case action
case "1"
searchclass="书名"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookname like '%"&searchkey&"%' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
case "2"
searchclass="作者"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookzz like '%"&searchkey&"%' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
case "3"
searchclass="出版社"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookchuban like '%"&searchkey&"%' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
case "4"
searchclass="ISBN"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,isbn,bookdate,adddate from shop_books where isbn='"&searchkey&"' and huiyuanjia<"&jiage&" and anclassid="&anclassid,conn,1,1
end select
else
'//分类为空。
select case action
case "1"
searchclass="书名"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookname like '%"&searchkey&"%' and huiyuanjia<"&jiage,conn,1,1
case "2"
searchclass="作者"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookzz like '%"&searchkey&"%' and huiyuanjia<"&jiage,conn,1,1
case "3"
searchclass="出版社"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,bookdate,adddate from shop_books where bookchuban like '%"&searchkey&"%' and huiyuanjia<"&jiage,conn,1,1
case "4"
searchclass="ISBN"
rs.open "select bookid,bookname,bookzz,bookcontent,shichangjia,huiyuanjia,bookpic,isbn,bookdate,adddate from shop_books where isbn='"&searchkey&"' and huiyuanjia<"&jiage,conn,1,1
end select
end if
end if%>
<table width="776" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="5"></td>
</tr>
</table>
<table width="776" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#009999">
<form name="searchform" method="post" action="research.asp" >
<tr><td align="center"> <img src="images/search.gif" width="64" height="16" >
<td><input name="searchkey" type="text1" size="30" value="请输入关键字" onFocus="this.value=''">
<td>类别
<td><select style=width:80px name="action" id="action">
<option value="1" selected>书名</option>
<option value="2">作者</option>
<option value="3">出版社</option>
<option value="4">ISBN</option>
</select>
<td><input type="submit" name="Submit" value="立即查询" onClick="return check();" >
<td><input type="button" name="Submit2" value="高级查询" onClick="location.href='search.asp'">
</tr></form>
</table>
<table width="776" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="2"></td>
</tr>
</table>
<table width="776" border="0" align="center" cellpadding="1" cellspacing="1">
<tr><td>
<table width="776" border="0" height=25 align="center" cellpadding="0" cellspacing="0" bgcolor="#DEE7F7">
<tr>
<td width=42% style="padding-left:6px">
<%if searchkey="" then
response.write "<p align='center' >请输入查询的关键字!</p>"
response.End
else
if len(searchkey)>30 then
response.Write "<script language='javascript'>alert('对不起,您输入的关键字太长!');window.location.reload('research.asp')</script>"
else
response.write "<li type=disc>在聚知图书网中检索到相关的图书有<font color=red>"&rs.recordcount&"</font>条"
response.write "<td>您查询的关键字是:<font color=red>"&searchkey&"</font>"
response.write "<td>类别是:<font color=red>"&searchclass&"</font>"
end if
end if%></td>
</tr>
</table>
</tr>
</table>
<%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="776" border="0" align="center" cellpadding="0" cellspacing="0" >
<%do while not rs.eof%>
<tr>
<td rowspan=5 vAlign=top style="PADDING-LEFT: 6px"><img height=103 hspace=20
src="images/bg_book.gif" width=71 vspace=5 border=0> <P style="MARGIN-TOP: -112px">
<IMG height=96 alt=图书封面 hspace=20 src=
<%if trim(rs("bookpic"))="" then
response.write "images/emptybook.gif"
else
response.write trim(rs("bookpic"))
end if%>
width=65 vspace=3 border=0></A></tr>
<tr>
<td bgcolor="#FFFFFF">图书名称:<%
Dim SelStar,SelLength,selstring,leftstring,rightstring
'//定位关键字的位置
SelStart=instr(1,rs("bookname"),searchkey,1)
if selstart<>0 then
SelLength=Len(searchkey)
'//取关键字符
selstring=mid(rs("bookname"),SelStart,SelLength)
leftstring=left(rs("bookname"),SelStart-1)
rightstring=right(rs("bookname"),(len(rs("bookname"))-SelLength-len(leftstring)))
'//显示整个字符
response.write "<a href=book.asp?id="&trim(rs("bookid"))&" target=_blank>"&leftstring&"<font color=red>"&selstring&"</font>"&rightstring&"</a>"
else
response.write "<a href=book.asp?id="&trim(rs("bookid"))&" target=_blank>"&trim(rs("bookname"))&"</a>"
end if%></td>
<tr>
<td bgcolor="#FFFFFF">(上架时间:<%=year(rs("adddate"))&"-"&month(rs("adddate"))&"-"&day(rs("adddate"))%>)</td>
<tr>
<td bgcolor="#FFFFFF">市场价:<%=formatnumber(rs("shichangjia"),2)&"元"%>
会员价:<%="<font color=red>"&formatnumber(rs("huiyuanjia"),2)&"</font>元"%>
立即节省:<%="<font color=red>"&formatnumber(round(rs("shichangjia")-rs("huiyuanjia"),2),2)&"</font>元"%></td></div>
<tr>
<td>
<%if len(trim(rs("bookcontent")))>80 then
response.write " "&left(trim(rs("bookcontent")),77)&"..."
else
response.write " "&trim(rs("bookcontent"))
end if%>
<tr>
<td colspan=2>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#FFFFFF" align="right" width="90%"><%response.write "<a href=# onClick=""javascript:window.open('add_bk.asp?bookid="&rs("bookid")&"&purchase=1','','width=730,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;""><img src=images/buy.gif width=49 height=14 border=0></a>"%></div></td>
<td bgcolor="#FFFFFF" align="right"><%response.write "<a href=# onClick=""javascript:window.open('shoucang.asp?id="&rs("bookid")&"&action=add','','width=730,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;""><img src=images/shoucang.gif width=49 height=14 border=0></a>"%></div></td>
</tr>
</table>
<hr>
<tr><td height=5>
<% 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="¤tpage&">"
Response.Write " <input type='submit' class='contents' value='GO' name='cndok'></form>"
End Function
%>
<!--#include file="copyright.asp"-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -