搜索拦代码
<table width="329" border='0' align='right' cellpadding='0' cellspacing='0'>
<form method=post action="search.asp">
<tr align="right">
<td width="246" valign='middle'><input type='text' name='keyword' id="keyword" value="请输入关键字" size='12' >
<select name='adprofession'>
<option value=''selected>行业类别</option>
<% set rs=server.createobject("adodb.recordset")
sql="select * from adprofession order by adprofession desc"
rs.open sql,conn,3,3
do while not rs.eof %>
<option value="<%=rs("adprofession")%>"><%=trim(rs("adprofessionname"))%></option>
<%rs.movenext
loop
rs.close
%>
</select>
<select name='adinplace'>
<option value='' selected>地区</option>
<% set rs=server.createobject("adodb.recordset")
sql="select * from adinplace order by adinplace desc"
rs.open sql,conn,3,3
do while not rs.eof %>
<option value="<%=rs("adinplace")%>"><%=trim(rs("adinplacename"))%></option>
<%rs.movenext
loop
rs.close
%>
</select> </td>
<td width='83' valign='bottom' >
<input name="image" type=image src='pic/search.jpg' align="middle" width=82 /> </td>
</tr>
</form>
</table>
search.asp页代码:
<!--#include file="conn.asp"-->
<style type="text/css">
body {font-family: "宋体";font-size:9pt;background-color:#ffffff;margin-left:0pt;margin-top:0pt}
td,input,select {font-family:宋体;font-size:9pt; color:#000000}
A:link,A:active,A:visited {text-decoration: none; color: #555555}
A:hover {text-decoration: underline; color:#b40000}
<!--
.central {
font-family: Arial, Helvetica, sans-serif;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
background-repeat: repeat;
background-position: left top;
background-color: #790000;
}
#Layer1 {
position:absolute;
left:193px;
top:85px;
width:85px;
height:515px;
z-index:0;
overflow: scroll;
background-color: #790000;
font-family: Arial, Helvetica, sans-serif;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
text-transform: capitalize;
}
.STYLE5 {color: #FFffff}
.STYLE6 {color: #FFFFFF}
-->
</style>
<style>
body {SCROLLBAR-FACE-COLOR:##FFCC99;
SCROLLBAR-HIGHLIGHT-COLOR:#790000;
SCROLLBAR-SHADOW-COLOR:#790000;
SCROLLBAR-ARROW-COLOR:#FFFFFF;
SCROLLBAR-BASE-COLOR:#000000;
SCROLLBAR-DARK-SHADOW-COLOR:#FFFFFF}
</style>
<!--#include file="head.asp"-->
<%
dim rs,sql
set rs=server.createobject("adodb.recordset")
%>
<table width="780" height="438" border="0" align="center" bgcolor="#790000" >
<tr>
<th width="93" height="320" rowspan="2"align="center" valign="top" bordercolor="#CCCCCC" scope="row"><img src="pic/profession.jpg" width="93" height="28" />
<div style="width:93;height:490;overflow-x:hidden;overflow-y:scroll">
<script>
//使元素出现横向滚动条
document.write(new Array(20).join(""))
//使元素出现纵向滚动条
document.write(new Array(20).join(""))
</script>
<table width="75%" border="0">
<tr>
<th scope="row">
<table width="87" border="0" align="left" class="central" >
<td align="center" valign="top">
<tr>
<th width="81" align="left" valign="top" class="central" scope="row">
<%
set rs=server.createobject("adodb.recordset")
sql="select * from adprofession order by adprofession desc"
rs.open sql,conn,1,1
%>
<table width="65" border="0" align="left" bgcolor="#FF0000" class="central">
<%do while not rs.eof%>
<tr align="left" valign="top">
<th align="center" background="pic/littleprofession.jpg" class="central" scope="row"><a href="search.asp"><%=rs("adprofessionname")%></a></th>
</tr>
<%
rs.movenext
loop
%>
</table>
</th>
</tr>
<td height="2" align="center" valign="top"></td>
</table></th>
</tr>
</table>
</div>
</th>
<td width="680" height="26" valign="top">
<table width="680" height="30" border="0" class="central">
<tr bordercolor="#FFFFFF">
<%
set rs=server.createobject("adodb.recordset")
sql="select * from adinplace order by adinplace asc"
rs.open sql,conn,1,1
%>
<%do while not rs.eof%>
<td width="674" align="center" valign="middle" bordercolor="#FFFFFF" background="pic/placesearch.jpg" bgcolor="#FFFFCC" class="central"><a href="search.asp"><%=rs("adinplacename")%></a></td>
<%
rs.movenext
loop
%>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top"><table width="100%" height="5" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width=478 height="2" style="border-bottom:#cccccc 1px solid" bgcolor="f7f7f7">
<b>搜索结果</b>>> </td>
</tr>
<tr>
<td width="478">
<% on error resume next
dim page,keyword,cid2,cid1
page=request.querystring("page")
if page="" then page=1
if not(isnumeric(page)) then page=1
if page<1 then page=1
page=int(page)
if request("sql")<>"" then
sql=request("sql")
else
keyword=trim(request("keyword"))
adinplace=request("adinplace")
adprofession=request("adprofession")
set function1=request("function1")
if keyword<>"" then
sql="select * from adtable where adname like '%"&keyword&"%'"
end if
if adinplace<>"" then
sql=sql&" and adinplace='"&cstr(adinplace) & "'"
end if
if adprofession<>"" then
sql=sql&" and adprofession='"&cstr(adprofession)&"'"
end if
end if
rs.open sql,conn,3,3
if rs.eof then
response.write "<br>无相关商品"
rs.close
else
rs.pagesize=10
totalrec=rs.recordcount
totalpage=rs.pagecount
if page>totalpage then page=totalpage
rs.absolutepage=page
rs.cachesize=rs.pagesize
i=0
dim id(),adname(),adplace(),adtel(),adurl(),adphopo(),adprofession(),adinplace(),adintroduction()
do while not rs.eof and (i<rs.pagesize)
i=i+1
redim preserve id(i),adname(i),adplace(i),adtel(i),adurl(i),adphopo(i),adprofession(i),adinplace(i),adintroduction(i)
id(i)=rs("id")
adname(i)=rs("adname")
adplace(i)=rs("adplace")
adtel(i)=rs("adtel")
adurl(i)=rs("adurl")
adphopo(i))=rs("adphopo")
adprofession(i)=rs("adprofession")
adinplace(i),)=rs("adinplace")
adintroduction(i)=rs("adintroduction")
rs.movenext
loop
rs.close
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width=2> </td>
<td width="515" >
<%
for i=1 to ubound(id)
%>
<table width="100%" height="289" border="1" align="center" bordercolor="#660000">
<tr>
<td align="center" colspan="2" class="title" height="20"><strong>广告内容</strong></td>
</tr>
<tr>
<td width="116" height="22"><strong>广告名</strong></td>
<td width="305"><%=rs("adname")%></td>
</tr>
<tr>
<td width="116" height="21">
<strong>广告图片</strong> </td>
<td width="305"><%=rs("adphopo")%></td>
</tr>
<tr>
<td width="116" height="21">
<strong>广告联系人电话</strong> </td>
<td width="305"><%=rs("adtel")%></td>
</tr>
<tr>
<td width="116" height="21">
<strong>何地广告</strong> </td>
<td width="305"><%=rs("adplace")%></td>
</tr>
<tr>
<td width="116" height="21">
<strong>广告网址</strong> </td>
<td width="305"><%=rs("adurl")%></td>
</tr>
<tr>
<td width="116" height="19">
<strong>地区</strong> </td>
<td width="305"><%=rs("adinplace")%></td>
</tr>
<tr>
<td height="13">
<strong>所属行业</strong> </td>
<td width="305"><%=rs("adprofession")%></td>
</tr>
<tr>
<td height="89">
<strong>广告介绍</strong> </td>
<td width="305"><%=rs("adintroduction")%></td>
</tr>
<tr> </tr>
</table>
<%next%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height=10></td>
</tr>
<tr>
<td width=478 height="23">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70%" align="right">
<form method="POST" action="search.asp?page=<%=page-1%>" name=form2>
<input type="hidden" name="sql" value="<%=sql%>">
<p align="right">第<%=page%>页/共<%=totalpage%>页
<%if page-1>0 then%>
<a href="javascript:document.form2.submit();">上一页</a>
<%else%>
上一页
<%end if%>
</form> </td>
<td width="30%" align="left">
<form method="POST" action="search.asp?page=<%=page+1%>" name=form3>
<input type="hidden" name="sql" value="<%=sql%>">
<%if page+1<=totalpage then%>
<a href="javascript:document.form3.submit();">下一页</a>
<%else%>
下一页
<%end if%>
</form> </td>
</tr>
</table> </td>
</tr>
</table> </td>
</tr>
</table>
<%end if%> </td>
</tr>
</table>
</td>
</tr>
</table>
<!--#include file="foot.asp"-->
[此贴子已经被作者于2006-8-18 20:33:23编辑过]