海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com
【字体设置:大 中 小】
下面是一个搜索并分页的例子,在写分页的时候一定要把搜索的关键字放到分页的代码中进行传递,否则,翻页的时候就会出现错误了。
<!--#include file="conn.asp"-->
<%
'过滤搜索内容中的特殊字符
FUNCTION txtToURL(tekst)
Tekst_temp = tekst
Tekst_temp = Replace(Tekst_temp,"<","<")
Tekst_temp = Replace(Tekst_temp,">",">")
Tekst_temp = Replace(Tekst_temp,"'","")
Tekst_temp = Replace(Tekst_temp,"chr(13)","<br />")
Tekst_temp = Replace(Tekst_temp,"chr(10)","<br />")
Tekst_temp = Replace(Tekst_temp,"#","<br />")
Tekst_temp = Replace(Tekst_temp,Chr(13),"<br />")
Tekst_temp = Replace(Tekst_temp,"[","<B>")
Tekst_temp = Replace(Tekst_temp,"]","</B>")
Tekst_temp = Replace(Tekst_temp,"~","")
Tekst_temp = Replace(Tekst_temp,"%","")
Tekst_temp = Replace(Tekst_temp,"_","")
Tekst_temp = Replace(Tekst_temp,"-","")
Tekst_temp = Replace(Tekst_temp,"+","")
Tekst_temp = Replace(Tekst_temp,"|","")
Tekst_temp = Replace(Tekst_temp,"\","")
Tekst_temp = Replace(Tekst_temp,"/","")
txtToURL = Tekst_temp
END FUNCTION
%>
<%
dim keyword
dim sql
dim rs
dim findword
keyword=txtToURL(request("keyword"))
findword="name and content like '%"&keyword&"%' "
dim page,k,tmppage
If Len(Trim(Request("page")))=0 Then '返回目标页码的判断
page=1
Else
page=CInt(Trim(Request("page")))
End If
set rs=server.createobject("adodb.recordset")
%>
<head>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<link href="a.css" rel="stylesheet" type="text/css">
</head>
<center><form name="new" action="search.asp" method="post">
<font color="<%=mycolor%>">请输入你要查询的关键字:</font>
<INPUT class=input2
name=keyword size="20"> <INPUT class=input2 name=B1 type=submit value="提 交">
<INPUT class=input2 name=B2 type=reset value=重新来过>
<%
sql="select * from article where "&findword&" order by browse desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<br>"
response.write "<br>"
response.write ("<div align=center><font color="&mycolor&">没有找到你要的记录,请尝试使用其它关键字进行搜索</font></div>")
else
%>
<% if keyword<>"" then%>
<table border="1" width="64%" id="table1" cellspacing="0" bordercolor="<%=mycolor%>" cellpadding="0" height="45">
<tr>
<td align="center" width="69%" height="22" background="skin/<%=skin%>/a3.gif">
<font color="#FFFFFF"><b>文章标题</b></font></td>
<td align="center" width="11%" height="22" background="skin/<%=skin%>/a3.gif">
<font color="#FFFFFF"><b>所属类别</b></font></td>
<td align="center" width="8%" height="22" background="skin/<%=skin%>/a3.gif">
<font color="#FFFFFF"><b>点击数</b></font></td>
<td align="center" width="11%" height="22" background="skin/<%=skin%>/a3.gif">
<font color="#FFFFFF"><b>发布时间</b></font></td>
</tr>
<%
rs.PageSize=20
if not rs.eof then
rs.AbsolutePage=page
for k=1 to rs.PageSize
%>
<tr>
<td width="69%" height="21"> <a href="showarticle.asp?sort=<%=rs("sort")%>&id=<%=rs("编号")%>" target=_blank><%=rs("name")%></a></td>
<td width="11%" height="21">
<p align="center"><a href=show.asp?sort=<%=rs("sort")%> target=_blank><%=rs("sort")%></a></td>
<td align="center" width="8%" height="21"> <%=rs("browse")%> </td>
<td width="11%" height="21"> <%=rs("date")%></td>
</tr>
<%
rs.movenext
if rs.EOF Then Exit For
next
end if
%>
</table> <table width="547" height="30" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" height="30" align="center">
<%
if page <>1 then
Response.Write "<a href=search.asp?page=1&keyword="&keyword&">首页</a> "
end if
tmppage = page - 1
if tmppage <= 0 then
tmppage = 1
else
Response.Write"<a href=search.asp?page="&tmppage&"&keyword="&keyword&">上一页</a>"
end if
tmppage = page + 1
if tmppage >rs.PageCount then
tmppage = page
else
Response.Write " <a href=search.asp?page="&tmppage&"&keyword="&keyword&">下一页</a> "
end if
if Cstr(page) <> Cstr(rs.PageCount) and Cstr(rs.PageCount) <> 0 then
Response.Write "<a href=search.asp?page="&rs.PageCount&"&keyword="&keyword&">尾页</a>"
end if
if Cstr(rs.PageCount) <> 0 then
Response.Write " 第<font color='#CCCCCC'>" & page & "/"&rs.PageCount&"</font>页"
end if
Response.Write " 共有<font color='#CCCCCC'>"&rs.RecordCount&"</font>条记录"
%>
</td>
</tr><%end if
end if%>
发表评论 - 不要忘了输入验证码哦!