search.asp
来自「asp的新闻网站」· ASP 代码 · 共 295 行
ASP
295 行
<%
'*********************************************************************************
'模块名称:新闻搜索
'开发人:佟庆涛
'时间:2001年2月8日
'*********************************************************************************
%>
<%
dim rs '数据访问对象
dim sql 'select 语句
dim i '循环控制变量
dim flag '文件头标志
dim table '数据表名 (news_info or new_special
dim path1 '新闻信息查看文件的路径及文件名
%>
<%'数据库连接包含文件 %>
<!--#include file="odbc.asp"-->
<!--#include file="showbody.asp">
<!--#include file="../include/checkserver.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../style.css">
<title>千夜网->新闻->新闻搜索</title>
<!--#include file="script.asp"-->
</head>
<%
'定义recordset对象
set rs=server.CreateObject ("adodb.recordset")
%>
<body topmargin="3" leftmargin="3">
<div align="center">
<% '网页头部包含文件
flag="000000"%>
<!--#include file="secondhead.asp"-->
<center>
<table border="0" width="770" cellspacing="0" cellpadding="0">
<tr>
<td width="20%"
bgcolor="#F5F5F5" valign="top" style="border-left: 6px solid rgb(230,230,230)">
<p align="center">
<%'新闻搜索%>
<form method="post" action="../include/search.asp" onsubmit="return check(this)" name=add>
<table border="0" width="98%">
<tr>
<td width="100%" height="30" colspan="2" ><p align="center"><br><img src="../images/pic-124.gif"></td>
</tr>
<tr>
<td width="100%" height="30" colspan="2"><p align="center">关键字: <br>
<input type="text" name="newstitle" size="13" value="<%=request("newstitle")%>"
style="background-color: rgb(235,235,235); border: 1px solid rgb(0,0,0)"> </td>
</tr>
<tr>
<td width="100%" height="30" colspan="2"><p align="center">日 期:<br>
<input type="text" name="year" size="4" value="<%=request("year")%>" maxLength=4
style="background-color: rgb(235,235,235); border: 1px solid rgb(0,0,0)">-<input
type="text" name="month" size="2" value="<%=request("month")%>" maxLength=2
style="background-color: rgb(235,235,235); border: 1px solid rgb(0,0,0)">-<input
type="text" name="day" size="2" value="<%=request("day")%>" onChange="daychange();" maxLength=2
style="background-color: rgb(235,235,235); border: 1px solid rgb(0,0,0)"></td>
</tr>
<tr>
<td width="80%"><p align="center">
<select name="menuid" size="1" style="font-size: 9pt">
<%set rs=server.CreateObject ("adodb.recordset")
sql="select * from news2_menu where visible='1' order by menuindex "
rs.Open sql,conn,3,1
%>
<%if not rs.EOF then
for i=1 to rs.RecordCount
if left(rs("menuid"),3)<>"012" then
%>
<option <%if left(rs.fields("menuid").value,3)=request("menuid") then response.write "selected" %> value="<%=left(rs("menuid"),3)%>"><%=rs("menuname")%></option>
<%
end if
rs.MoveNext
next
else
Response.Write "menu erro!"
end if
rs.Close %>
</select></td>
<td width="20%" height="20"><input border="0" src="../images/pic-057.gif" name="I1" type="image"></td>
</tr>
</table>
</form>
</p>
</td>
<td width="60%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"><p align="left"><img src="../images/pic-203.gif"> </td>
<td width="50%"><p align="right"><img src="../images/pic-204.gif"> </td>
</tr>
</table>
<br>
<table border="0" width="100%">
<tr>
<td width="100%">
<ul>
<%
sql=""
if request("mySql")="" then '第一次调用
if trim(request("menuid"))="" then
response.write "请选择新闻栏目"
response.end
else
sql=" where left(menuid,3)='"&trim(request("menuid"))&"'"
end if
if trim(request("menuid"))="010" then '专题新闻
table="news2_special"
path1="../looknews_zt.asp"
else '普通新闻
table="news2_info"
path1="../looknews.asp"
end if
if trim(request("newstitle"))<>"" then
if sql<>"" then
sql=sql&" and "
end if
sql=sql&" newstitle like '%"&trim(request("newstitle"))&"%'"
end if
if trim(request("year"))<>"" then
sql=sql&" and year(regtime)="&clng(request("year"))
if trim(request("month"))<>"" then
sql=sql&" and month(regtime)="&clng(request("month"))
end if
if trim(request("day"))<>"" then
sql=sql&" and day(regtime)="&clng(request("day"))
end if
end if
sql="select * from "&table&sql&" order by regtime desc "
else '翻页调用
sql=request("mySql")
end if
%>
<%
rs.Open sql, conn, 3, 1
%>
<%
if rs.eof then
response.write "没有您要查的新闻!"
else
response.write "<p><b>共检索到"&rs.RecordCount&"条符合条件的新闻</b></p>"
end if
%>
<!--#include file="../include/rollpage.asp"-->
<%
if not rs.EOF then
rs.PageSize = 15
rs.AbsolutePage = getPageNo(rs)
for i=1 to rs.PageSize
If rs.EOF Then Exit For
%>
<li><a class="l7" href="<%=path1%>?menuid=<%=rs("menuid")%>&infoid=<%=rs("infoid")%>" target="_blank"><%=rs("newstitle")%></a> <font size="2" color="#808080"> <%showtime(rs("regTime"))%></font><br>
</li>
<%rs.MoveNext
if right(trim(cstr(i)),1)="0" then '隔十行空一行*******************************************
Response.Write "<br>"
end if
If rs.EOF Then Exit For
next
end if
%>
</ul>
</td>
</tr>
</table>
<form>
<input type=hidden value=<%=request("menuid")%> name=menuid> <!--记忆推荐位-->
<input type=hidden value=<%=request("year")%> name=year> <!--记忆推荐位-->
<input type=hidden value=<%=request("month")%> name=month> <!--记忆推荐位-->
<input type=hidden value=<%=request("day")%> name=day> <!--记忆推荐位-->
<input type=hidden value=<%=request("newstitle")%> name=newstitle> <!--记忆推荐位-->
<%call listPage(rs)%>
<% rs.Close %>
</form>
</td>
<td width="20%" bgcolor="#F5F5F5" valign="top"> <img src="../images/pic-205.gif">
</td>
</tr>
</table>
</center>
</div>
<hr width="90%" size="1" color="#D52B73">
<div align="center"><center>
<!--#include file="bottom.txt"-->
</table>
</center></div>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?