多关键字查询怎么作

kahntang 2001-07-19 12:18:24
...全文
83 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
chassis 2001-10-10
gz
回复
kahntang 2001-07-26
大哥再帮我做个嵌套查询吧!
回复
freezwy 2001-07-22
下面上一个根据4个条件查询的例子,如果需要更多的查询条件,可以更改里面的函数。
<!--#include file="../inc/chkstr.asp"-->
<%
const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
%>
<HTML><TITLE>搜索结果</TITLE>
<link rel=stylesheet href=../style.css>
<BODY topmargin=0 bgcolor="#FFFFFF" oncontextmenu="javascript:self.event.returnValue=false">
<!--#include file=../head.inc-->
<%
skey=checkstr(trim(request("skey")))
vocation=trim(request("vocation"))
ptime=cint(request("ptime"))
area=request("area")
%>
<p><a href="s_keyword.asp">快速搜索</a>-->>搜索结果
<%
on error resume next
sql="select a.comname,b.username,b.cid,b.vname,b.applynum,b.salary,b.addtime from company a,cposition b where a.loginname=b.username and dateadd(DD,"&ptime&",b.addtime)>getdate()"
if vocation<>"" then
sql=sql&" and b.vocation='"&vocation&"'"
end if
if area<>"" then
sql=sql&" and left(b.hukou,2)='"&area&"'"
end if
if skey<>"" then
sql=sql&" and (a.comname like '%"&skey&"%' or b.vname like '%"&skey&"%')"
end if
sql=sql&" order by b.cid desc"
'response.write sql
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,session("conn"),1,1
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
' showpage totalput,MaxPerPage,"quicksearch.asp",vocation,area,ptime,skey
showContent
showpage totalput,MaxPerPage,"quicksearch.asp",vocation,area,ptime,skey
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
' showpage totalput,MaxPerPage,"quicksearch.asp",vocation,area,ptime,skey
showContent
showpage totalput,MaxPerPage,"quicksearch.asp",vocation,area,ptime,skey
else
currentPage=1
' showpage totalput,MaxPerPage,"quicksearch.asp",vocation,area,ptime,skey
showContent
showpage totalput,MaxPerPage,"quicksearch.asp",vocation,area,ptime,skey
end if
end if
end if
rs.close
set rs=nothing
sub showContent
i=0
%>
<table border=0 cellspacing=1 width="91%" align="center" cellspacing=0 cellspadding=0>
<tr bgcolor="#f3f3fa">
<td align=middle width="6%">
<div align="center"><font color="#0000FF"><span >序号</span></font></div>
</td>
<td align=middle width="31%">
<div align="center"><font color="#0000FF"><span >公司名称</span></font></div>
</td>
<td align=middle width="23%">
<div align="center"><font color="#0000FF"><span >招聘职位</span></font></div>
</td>
<td align=middle width="11%">
<div align="center"><font color="#0000FF"><span >招聘人数</span></font></div>
</td>
<td align=center width="13%"><font color="#0000FF"><span >薪金</span></font></td>
<td align=middle width="16%">
<div align="center"><font color="#0000FF">发布日期</font></div>
</td>
</tr>
<%do while not rs.eof%>
<tr>
<td align=middle bgcolor=#ffffff width="6%">
<%if currentpage=1 then%>
<%=i+1%>
<%else%>
<%=maxperpage*currentpage+i%>
<%end if%>
</td>
<td bgcolor=#ffffff width="31%" >
<a href="company.asp?cid=<%=trim(rs(1))%>" target="_blank"><%=rs(0)%></a></td>
<td bgcolor=#ffffff width="23%" align="center"> <a href="jobinfo.asp?cid=<%=trim(rs(1))&"&jobno="&rs(2)%>" target="_blank"><%=rs(3)%></a></td>
<td align=center bgcolor=#ffffff width="11%" >
<%=rs(4)%> </td>
<td align=right bgcolor=#ffffff width="13%" >
<%=rs(5)%>
</td>
<td align=right bgcolor=#ffffff width="16%" ><%=formatdatetime(rs(6),1)%></td>
</tr>
<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</table>
<p>
<% end sub
function showpage(totalnumber,maxperpage,filename,vocation,area,ptime,skey)
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&">"
response.write "<p align='center'>分页 "
if CurrentPage<2 then
response.write "首页 上一页 "
else
response.write "<a href="&filename&"?page=1"&"&area="&area&"&skey="&skey&"&ptime="&ptime&"&vocation="&vocation&">首页</a> "
response.write "<a href="&filename&"?vocation="&vocation&"&area="&area&"&skey="&skey&"&ptime="&ptime&"&page="¤tPage-1&">上一页</a> "
end if
if n-currentpage<1 then
response.write "下一页 尾页"
else
response.write "<a href="&filename&"?vocation="&vocation&"&area="&area&"&skey="&skey&"&ptime="&ptime&"&page="&(CurrentPage+1)
response.write ">下一页</a> <a href="&filename&"?vocation="&vocation&"&area="&area&"&skey="&skey&"&ptime="&ptime&"&page="&n&">尾页</a>"
end if
response.write " 页次:<strong><font color=red>"¤tPage&"</font>/"&n&"</strong>页 "
response.write " 共<b>"&totalnumber&"</b>条信息 <b>"&maxperpage&"</b>条信息/页 "
response.write " 转到:<input type='text' name='page' size=4 maxlength=10 class=smallInput value="¤tpage&">"
response.write "<input class=buttonface type='submit' value='Go' name='cndok'></span></p></form>"
end function
%>
</p>
</BODY>
</HTML>
由于一些原因,我还是删除了一些东西,自己修改成自己能用的吧。
回复
tripofdream 2001-07-22
http://www.csdn.net/expert/topic/176/176312.shtm
回复
sundna 2001-07-21
SQL: Select * from fromname by 关键字1,关键字2,关键字3...关键字n
回复
kahntang 2001-07-21
对,并将结果分页显示!
回复
tripofdream 2001-07-19
是多项查询吧
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2001-07-19 12:18
社区公告
暂无公告