asp中建立搜索的不同方法
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
%>
相关文章
- 使用 Flash Builder 的 Apple iOS 开发过程
使用 Flash Builder 的 Apple iOS 开发过程 iOS 开发和部署过程概述 构建、调试或部署 iOS 应用程序前的准备工作 在测试、调试或安装 iOS 应用程序时选择的文件 将应用程序部署到 Apple App Store 时选择的文件 在使用 Flash Builder 开发 iOS 应用程序之前,必须…...
2023/8/14 10:12:43 - exchange日常管理之九:升级SP1后的灾难恢复
将exchange 2007升级到了exchange 2010,但是没有打最新的SP1补丁和累积更新,没想到这补丁一打就出问题了,汗了一把啊。 升级过程摘要 1、在前端服务器和后端服务器上安装microsoft office filter pack 2.0 2、停掉后端的beremote备份进程 3…...
2023/3/16 17:29:51 - iOS开发 - js oc相互调用
2019独角兽企业重金招聘Python工程师标准>>> 首先导入 JavaScriptCore.framework 框架 #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <JavaScriptCore/JavaScriptCore.h>protocol ServerJSProtocol <JSExport>// 微…...
2023/8/15 6:10:40 - git学习之创建版本库
创建版本库 什么是版本库呢?版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改、删除,Git都能跟踪,以便任何时刻都可以追踪…...
2023/8/14 11:54:39 - List集合中的数据按照某一个属性进行分组
有的时候,我们需要在java中对集合中的数据进行分组运算。例如:Bill对象有money(float)和type(String)属性,现有个集合List<Bill>,需要按照Bill的type属性进行分组,计算money的总和。有以下两种思路: …...
2023/8/15 6:04:00 - 游戏编程性能优化--------------------------------------------------------------------------------------...
游戏编程性能优化------------------------------------------------------------------------------------------- 1.全局变量名尽量用缩写,尽可能短,可以减小程序最终生所的体积 2.for循环在较大的循环空间,写成几个循环,以利用…...
2023/3/16 12:35:44
最新文章
- 使用 Flash Builder 的 Apple iOS 开发过程
使用 Flash Builder 的 Apple iOS 开发过程 iOS 开发和部署过程概述 构建、调试或部署 iOS 应用程序前的准备工作 在测试、调试或安装 iOS 应用程序时选择的文件 将应用程序部署到 Apple App Store 时选择的文件 在使用 Flash Builder 开发 iOS 应用程序之前,必须…...
2023/8/14 10:12:43 - exchange日常管理之九:升级SP1后的灾难恢复
将exchange 2007升级到了exchange 2010,但是没有打最新的SP1补丁和累积更新,没想到这补丁一打就出问题了,汗了一把啊。 升级过程摘要 1、在前端服务器和后端服务器上安装microsoft office filter pack 2.0 2、停掉后端的beremote备份进程 3…...
2023/3/16 17:29:51 - iOS开发 - js oc相互调用
2019独角兽企业重金招聘Python工程师标准>>> 首先导入 JavaScriptCore.framework 框架 #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <JavaScriptCore/JavaScriptCore.h>protocol ServerJSProtocol <JSExport>// 微…...
2023/8/15 6:10:40 - git学习之创建版本库
创建版本库 什么是版本库呢?版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改、删除,Git都能跟踪,以便任何时刻都可以追踪…...
2023/8/14 11:54:39 - List集合中的数据按照某一个属性进行分组
有的时候,我们需要在java中对集合中的数据进行分组运算。例如:Bill对象有money(float)和type(String)属性,现有个集合List<Bill>,需要按照Bill的type属性进行分组,计算money的总和。有以下两种思路: …...
2023/8/15 6:04:00 - 游戏编程性能优化--------------------------------------------------------------------------------------...
游戏编程性能优化------------------------------------------------------------------------------------------- 1.全局变量名尽量用缩写,尽可能短,可以减小程序最终生所的体积 2.for循环在较大的循环空间,写成几个循环,以利用…...
2023/3/16 12:35:44 - 国内可使用chatGPT的十三种方式
国内AI 1. 开放猫 Chat机器人https://mirrorchat.extkj.cn/ chat机器人: Chat机器人https://mirrorchat.extkj.cn/ 3.免费学习测试 免费学习测试https://chat.wuguokai.cn/#/chat/1683348236237 4.AI文本工具站 AI文本工具站一个用于提高工作效率的文本工具网站,应用…...
2023/8/14 13:04:36 - 基于ChatGPT3.5 API实现的私有化web程序源码+使用说明,一键部署属于自己定制化的 chatgpt web 程序
chatgpt-web 本项目可以一键部署属于自己定制化的 chatgpt web 程序(兼容gpt3.5), 只需下载release中对应平台的项目文件,修改配置后执行,打开 http://127.0.0.1:8080 ,便可以获得属于自己的chatgpt网站。 参考项目:co…...
2023/8/14 19:59:25 - ChatGPT Plus用户专享:86款高效功能插件,详尽安装与使用全攻略
在前天的文章中,我们介绍了 ChatGPT 开放的全新模式 Web Browsing(网页浏览),启用后 ChatGPT 就可以开始上网,收集最新的互联网资料进行作答。 其他关于chatgpt使用方面:请访问: 链接…...
2023/8/14 10:16:53 - ChatGPT自然语言处理的新里程碑
ChatGPT中文网是一个面向中国用户的聊天机器人网站,旨在为国内用户提供一个自然的环境、有趣、实用的聊天体验。它使用最新的自然语言处理技术来帮助用户更好地理解他们的聊天对话,还可以帮助用户解决日常生活中的问题,提供有趣的谈话内容以及…...
2023/8/15 8:22:45 - 国内版ChatGPT最全使用方法及使用用途技巧汇总
ChatGPT人工智能技术的出现确实会让一些人担心自己的工作会不会被取代。但实际上,人工智能技术只会替代那些可以被程序自动化的重复性、标准化、无脑力的工作,而对于需要人类创意、想象力和复杂思维的工作来说,AI人工智能技术的发展对于人类来…...
2023/8/14 10:55:47 - ChatGPT和Midjourney王炸组合,开启AI新时代
目录 序言 一:使用ChatGPT进行对话 二:调用newbies robot 三:举例说明 四:付费和使用限制 序言 随着人工智能技术的不断发展,越来越多的人开始使用人工智能工具来创作图画。在这里,我将分享如何结合Ch…...
2023/8/15 10:03:43