📄 ru_query.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="const.asp"-->
<!--#include file="char.asp"-->
<%
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
dim keyword
dim sql
dim rs
dim founderr
dim errmsg
dim findword
founderr=false
keyword=request("keyword")
if keyword="" then
response.write "<script language=javascript>"
response.write "alert('输入关键字');"
response.write "</script>"
response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
'如果禁止了script就执行下面语句
response.write "您没有输入关键字,无法查找,请<a href=index.asp>返回</a>"
response.end
founderr=True
else
keyword=replace(replace(replace(replace(keyword,"'","‘"),"<","<"),">",">")," "," ")
findword="title and content like '%"&keyword&"%' "
end if
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
set rs=server.createobject("adodb.recordset")
%>
<html>
<head>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<LINK href="style.css" rel=stylesheet>
<title>搜索结果</title>
<body leftMargin=0 topmargin="0" marginwidth="0" marginheight="0" >
<table width=760 border="0" align=center cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" class="table">
<tr>
<td colspan="2" align=center ><img src="../love1.jpg" width="780" height="350">
<%
response.write "查询关键字:<strong><font color=#000000>"&keyword&"</font></strong>"
%>
<%
sql="select * from article where "&findword&" "
sql=sql&" order by articleid desc"
rs.open sql,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
showContent
showpage totalput,MaxPerPage,"ru_query.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"ru_query.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"ru_query.asp"
end if
end if
rs.close
end if
sub showContent
dim i ,content
i=0
%>
</td>
</tr>
<tr>
<td height="1" colspan="2" align=center ></td>
</tr>
<tr>
<td colspan="2" align=center valign="top" >
<table width="95%" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td height=10></td>
</tr>
</table>
<table border="0" width=95% cellspacing="0" cellpadding="1">
<tr>
<td valign="center" >
<%do while not rs.eof%>
<%=i+1%>≯<a href="list.asp?id=<%=rs("articleid")%>"><b><%=replace(rs("title"),""&keyword&"","<font color=red>"&keyword&"</font>")%></b></a><br>
<div style="padding:5px 20px">
<%
content=nohtml(rs("content"))
response.write left(content,60)
%>
......<span class="hittd"><strong><font color="#000000">[<%=rs("dateandtime")%>]</font></strong></span>
</div>
<%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
</td>
</tr>
</table>
<table width="95%" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td height=10></td>
</tr>
</table></td>
</tr>
<tr >
<td align=center valign="top">
<%
end sub
function showpage(totalnumber,maxperpage,filename)
dim n, i
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
if CurrentPage<2 then
response.write "找到"&totalnumber&"篇文章 | 首页 | 上一页 | "
else
response.write "找到"&totalnumber&"篇文章 | <a href="&filename&"?page=1&keyword="&keyword&">首页</a> | "
response.write "<a href="&filename&"?page="&CurrentPage-1&"&keyword="&keyword&">上一页</a> | "
end if
if n-currentpage<1 then
response.write "下一页 | 尾页 | "
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&keyword="&keyword&">"
response.write "下一页</a> | <a href="&filename&"?page="&n&"&keyword="&keyword&">尾页</a> | "
end if
response.write "页次:<strong>"&CurrentPage&"/"&n&"</strong>页 "
response.write "<b>"&maxperpage&"</b>篇文章/页 "
%>
<%
end function
%>
<%
set rs=nothing
conn.close
set conn=nothing
%></td>
<td align=center valign="top">
<TABLE cellSpacing=0 cellPadding=0 width="120" align=center border=0>
<TBODY><form method=post name=myform action=ru_query.asp>
<TR align="center">
<TD> <INPUT class=button maxLength=50 size=10 name=keyword></TD>
<TD> <INPUT type=image height=18 width=38 src="search.gif"
name=Submit></TD>
</TR></form>
</TBODY>
</TABLE></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -