searchfunction:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
sub searchinfo()
'如果是新查询''''''''''''''''''''
if request("search")="1" then
session("sessionok")=""
end if
''''''''''''''''''''''''''''''''如果不是新查询
dim select1,select2,selectyear,selectmonth,key
if session("sessionok")="ok" then
select1=session("select1")'按栏目
select2=session("select2")'按产品厂商或产品类别
selectyear=session("selectyear")
selectmonth=session("selectmonth")
selectdate=session("selectdate")'按日期
key=session("key")'关键字
else
select1=request("select1")'按栏目
select2=request("select2")'按其它
selectyear=request("selectyear")'按年
selectmonth=request("selectmonth")'按月
selectdate=selectyear &"-"& selectmonth &"-"&"01 01:01:01"
key=trim(request("key"))
if key="" then
response.Write("关键字不能为空!")
response.End()
end if
if select1="" and select2="" and selectyear="" then
response.Write("对不起,你没有指定条件!")
response.End()
end if
session("select1")=request("select1")'按栏目
session("select2")=request("select2")'按其它
session("selectyear")=request("selectyear")'按年
session("selectmonth")=request("selectmonth")'按月
session("selectdate")=selectyear &"-"& selectmonth &"-"&"01 00:00:00"
session("key")=trim(request("key"))
session("sessionok")="ok"
end if
'只选择按栏目查询
if select1<>"" and selectyear="" and select2="" then
search="newstype='"&select1&"' and title like '%"&key&"%' or newstype='"&select1&"' and content like '%"&key&"%' order by id desc"
sql="select title,id,createtime,newstype,url from T_news where "&search
end if
'按栏目和时间查询
if select1<>"" and selectyear<>"" and select2="" then
search="newstype='"&select1&"' and title like '%"&key&"%' and createtime>'"&selectdate&"' or newstype='"&select1&"' and content like '%"&key&"%' and createtime>'"&selectdate&"' order by id desc"
sql="select title,id,createtime,newstype,url from T_news where "&search
end if
'按栏目和厂商、产品类型查询
if select1<>"" and selectyear="" and select2<>"" then
if select2="cs" then
search="newstype='"&select1&"' and company like '%"&key&"%' order by T_news.id desc"
else
search="newstype='"&select1&"' and type like '%"&key&"%' order by T_news.id desc"
end if
sql="select title,T_news.id,createtime,newstype,T_news.url from T_co join T_news on T_co.id=T_news.companyid join T_class on T_news.classid=T_class.id where "&search
end if
'按栏目和时间和厂商、产品类型查询
if select1<>"" and selectyear<>"" and select2<>"" then
if select2="cs" then
search="newstype='"&select1&"' and createtime>'"&selectdate&"' and company like '%"&key&"%' order by T_news.id desc"
else
search="newstype='"&select1&"' and createtime>'"&selectdate&"' and type like '%"&key&"%' order by T_news.id desc"
end if
sql="select title,T_news.id,createtime,newstype,T_news.url from T_co join T_news on T_co.id=T_news.companyid join T_class on T_news.classid=T_class.id where "&search
end if
'按厂商、产品类型查询
if select2<>"" and select1="" and selectyear="" then
if select2="cs" then
search="company like '%"&key&"%' order by T_news.id desc"
else
search="type like '%"&key&"%' order by T_news.id desc"
end if
sql="select title,T_news.id,createtime,newstype,T_news.url from T_co join T_news on T_co.id=T_news.companyid join T_class on T_news.classid=T_class.id where "&search
end if
'按厂商、产品类型和时间查询
if select2<>"" and select1="" and selectyear<>"" then
if select2="cs" then
search="company like '%"&key&"%' and createtime>'"&selectdate&"' order by T_news.id desc"
else
search="type like '%"&key&"%' and createtime>'"&selectdate&"' order by T_news.id desc"
end if
sql="select title,T_news.id,createtime,newstype,url from T_co join T_news on T_co.id=T_news.companyid join T_class on T_news.classid=T_class.id where "&search
end if
'按时间查询
if select1="" and selectyear<>"" and select2="" then
search="title like '%"&key&"%' and createtime>'"&selectdate&"' or content like '%"&key&"%' and createtime>'"&selectdate&"' order by id desc"
sql="select title,id,createtime,newstype,url from T_news where "&search
end if
dim rs2
'sql="select title,T_news.id,createtime,newstype from T_co join T_news on T_co.id=T_news.companyid join T_class on T_news.classid=T_class.id where "&search
'response.Write(session("ok"))
'response.write sql
'response.end
set rs2=server.CreateObject("adodb.recordset")
rs2.open sql,conn,1,1
%>
<body leftmargin="0" topmargin="0"><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
<%
if rs2.eof and rs2.bof then
response.Write(" 没有找到记录!")
else
page=request("page")
if page="" then page="1"
rs2.pagesize=48
rs2.absolutepage=clng(page)
%>
<tr>
<td width="0%"></td>
<td colspan="2">关键字 <font color="#CC0000"><u><%=key%></u></color><font color="#000000"> 的检索结果:</font></td>
<tr>
<%
for i=1 to rs2.pagesize
if rs2.eof then exit for
newstype=rs2("newstype")
select case newstype
case "yj"
linke="zw_yjxw.asp"
case "mz"
linke="zw_mzcy.asp"
case "xc"
linke="zw_xpfb.asp"
case "cy"
linke="zw_cyts.asp"
case "qy"
linke="index-6.asp"
case "js"
linke="zw_jsyy.asp"
case "sj"
linke="zw_sjsl.asp"
end select
%>
<tr>
<td></td>
<td width="80%" height="22"><font size="1">◆ </font> <font color="#0033CC">
<%if isnull(rs2("url")) or rs2("url")="" then%>
<a href="<%response.write (linke)%>?id=<%=rs2("id")%>" target="_blank">
<%else%>
<a href="../<%=rs2("url")%>" target="_blank">
<%end if%>
<font color="#0033CC"><%=left(rs2("title"),22)%></font></a> </font></td>
<td><font color="#0033CC"><%=FormatDateTime(rs2("createtime"),2)%></font></td>
</tr>
<%
rs2.movenext
next
end if
%>
<tr>
<td></td>
<td colspan="2"><br> <hr align="left" width="100%">
<font size="2">
<%
if rs2.pagecount=1 then'如果只有一页则不必分页
else
p_i=request("P_i")'记录起始位置
if p_i="" then
p_i=1
else
p_i=clng(P_i)
end if
if clng(page)>1 then'如果当前不只一页
if clng(page)=p_i then
response.write("<a href='search.asp?page="&page-1&"&p_i="&(p_i)-10&"'>上一页</a> ")
else
response.write("<a href='search.asp?page="&page-1&"&p_i="&p_i&"'>上一页</a> ")
end if
end if
for i=p_i to rs2.pagecount
if i mod 10 = 0 then
if i=clng(page) then
response.write ("<font color='#333333'>[</font><font color=red>"&i&"</font><font color='#333333'>]</font>")
else
response.write ("<font color='#333333'>[<a href='search.asp?page="&i&"&p_i="&p_i&"'>"&i&"</a>]</font>")
end if
response.Write(" ")
if clng(page)=i then
P_i=p_i+10
end if
if clng(page)=i then
bottom=true
end if
exit for
end if
if i=clng(page) then
response.write ("<font color='#333333'>[</font><font color=red><b>"&i&"</b></font><font color='#333333'>]</font>")
else
response.write ("<font color='#333333'>[<a href='search.asp?page="&i&"&p_i="&p_i&"'>"&i&"</a>]</font>")
end if
response.Write(" ")
next
if rs2.pagecount>1 then
if clng(page)=rs2.pagecount then
else
response.write ("<a href='search.asp?page="&page+1&"&p_i="&p_i&"'>下一页</a>")
end if
end if
end if
%>
</font> </td>
</tr>
</table>
<%
end sub
%>