28,391
社区成员
发帖
与我相关
我的任务
分享
<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%dim action,searchkey,categoryid,jiage,shape,rs2,zkou,rs3,carat,caratpage
dim good,clar,cut,polish,tosay,arrows,zstype,fluore,bqj1,bqj2,goods
shape=request("shape")
good=request("good")
clar=request("clar")
cut=request("cut")
bqj1=request("bqj1")
bqj2=request("bqj2")
polish=request("polish")
tosay=request("tosay")
arrows=request("arrows")
zstype=request("zstype")
fluore=request("fluore")
categoryid=request.form("categoryid")
jiage=request.form("jiage")
action=request.QueryString("action")
searchkey=request.QueryString("searchkey")
if request("bqj1")<>"" then
caratpage=caratpage&"bqj1="&bqj1
end if
if request("bqj2")<>"" then
caratpage=caratpage&"&bqj2="&bqj2
end if
if categoryid="" then categoryid=request.QueryString("categoryid")
if jiage="" then jiage=request.QueryString("jiage")
if action="" then action=int(request.form("action"))
if searchkey="" then searchkey=trim(request.form("searchkey"))
%>
<%call sss()%>
<title><%=webname%>--商品搜索结果</title>
<!--#include file="include/header.asp"-->
<TABLE WIDTH="973" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" BGCOLOR=<%=bgclr1%>>
<TR><TD WIDTH="760" BGCOLOR=<%=bgclr1%> HEIGHT="22" ALIGN="CENTER">
<B><FONT COLOR="#FFFFFF">搜索结果</FONT></B></TD></TR></TABLE>
<table width="973" border="0" cellspacing="1" cellpadding="0" align="center" BGCOLOR=<%=bgclr1%>>
<tr> <td HEIGHT="200" VALIGN="TOP" BGCOLOR=<%=bgclr4%> WIDTH="100%"> <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=20
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 * from product where name like '%"&searchkey&"%' ",conn,1,1
case "2"
rs.open "select id,name,good,mark,introduce,price1,price2,discount,productdate from product where mark like '%"&searchkey&"%' ",conn,1,1
case "3"
rs.open "select id,name,good,mark,introduce,price1,price2,discount,productdate from product where introduce like '%"&searchkey&"%' ",conn,1,1
case "4"
rs.open "select id,name,good,mark,introduce,price1,price2,discount,detail,productdate from product where detail='"&searchkey&"' ",conn,1,1
end select
else
'//高级查询
if categoryid<>0 then '//判断查询分类,分类不为空。
select case action
case "1"
rs3="select * from product where name like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluors in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "2"
rs3="select * from product where mark like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluore in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "3"
rs3="select * from product where introduce like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluors in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "4"
rs3="select * from product wheree detail='"&searchkey&"' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluors in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
end select
else
'//分类为空。
select case action
case "1"
rs3="select * from product where name like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluore in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "2"
rs.open "select * where mark like '%"&searchkey&"%' and good in ("&good&") and zstype in ("&zstype&") and shape in ("&shape&") and price2<"&jiage,conn,1,1
case "3"
rs.open "select * from product where introduce like '%"&searchkey&"%' and good in ("&good&") and zstype in ("&zstype&") and shape in ("&shape&") and price2<"&jiage,conn,1,1
case "4"
rs.open "select * from product where detail='"&searchkey&"' and good in ("&good&") and zstype in ("&zstype&") and shape in ("&shape&") and price2<"&jiage,conn,1,1
end select
end if
end if
<a href='javascript:doSearch(page)'>下一页</a>
也可以加个参数page
function doSearch(pagenum){
for(){.........}
if(pagenum!=''){strUrl+='&page='&pagenum;}
$.get(strUrl,function(msg){$('#list').html(msg);});
}
如果你懂jquery,就好了.
示例:
<form id='searchForm'>
<input type='text' id='username' />
<input type='checkbox' id='ofun' value='1' />
<input type='button' id='' value='search' />
</form>
<div id='list'></div>
<script src='jquery.js'></script>
<script>
function doSearch(){
strUrl='dataList.asp?act=s';
for(var j=0;j<document.forms[0].elements.length;j++){
if(document.forms[0].elements[j].value!=''){
if(document.forms[0].elements[j].type='checkbox'&&document.forms[0].elements[j].checked){
strUrl+='&'+document.forms[0].elements[j].id+'='+document.forms[0].elements[j].value
}
else{
strUrl+='&'+document.forms[0].elements[j].id+'='+document.forms[0].elements[j].value;}
}
}
$.get(strUrl,function(msg){$('#list').html(msg);})
}
</script>
后台dataList.asp
<%
dim username,ofun
ofun=request.querystring("ofun")
username=request.querystring("username")
下面就按照你普通分页写法 写就行了.....
只不过<a href='javascript:gopage(1)'>First</a>
<a href='javascript:gopage("&page&"+1)'>Next</a>
%>