首页 | 心情日记 | 建站心得 | 编程技术 | 大盘分析 | 股市信息 | 学习园地 | 电脑技巧 | 物流外贸 | 另类其它 | 站长推荐 | 给我留言 | 相册

用户登陆
用户:
密码:
 
不保存保存一天
保存一月保存一年

站点日历
73 2024 - 3 48
     12
3456789
10111213141516
17181920212223
24252627282930
31


站点统计

最新评论

日志搜索

 标题   内容


ASP获取星期几的代码 一个不错的ASP加密和解密的程序
未知 ASP搜索并分页的例子   [ 日期:2010-03-17 18:25:39 ]   [ 来自:本站原创 ]

海外邮件中继,海外退信中继,美国高速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,"<","&lt;")
Tekst_temp = Replace(Tekst_temp,">","&gt;")
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>&nbsp;   
          <INPUT class=input2        
            name=keyword size="20">&nbsp;&nbsp; &nbsp;<INPUT class=input2 name=B1 type=submit value="提 交">
            &nbsp;&nbsp;&nbsp;&nbsp; <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">&nbsp;<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">&nbsp;<%=rs("browse")%>&nbsp;</td>
        <td width="11%" height="21">&nbsp;<%=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%>

暂时没有评论
   发表评论 - 不要忘了输入验证码哦!
作者: 用户:  密码:  我要注册 验证码: 
为防止广告注册机程序,验证码不会自动显示,请点击此处显示或者(刷新)验证码!
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
确定发布?
最多可以输入200个字,目前你已经输入了0个字;你今日还可以发表10条评论!
 
   

CopyRight © 2008-2010 广东金融学院030904班 All Rights Reserved
Powered by www.030904.com