result.asp

来自「这是一个学生毕业时做的教务系统」· ASP 代码 · 共 188 行

ASP
188
字号
<%@ Language=VBScript%>

<!--#include file=include/conn.asp -->
<%


request_BigClassName=Request.QueryString("BigClassName")
keyword=trim(Request.QueryString("keyword"))
page=Request.QueryString ("page")
if page="" then page=1

if request_BigClassName="" then
Response.Write "请选择您需要搜索的范围!"
Response.End
end if

if keyword="" then
Response.Write "请输入查询关键字!"
Response.End
end if


set rs=server.CreateObject("ADODB.RecordSet")
rs.Source="select * from BigClass order by BigClassID"
rs.Open rs.Source,conn,1,1

dim ArrayBigClassID(20),ArrayBigClassName(20)
BigClassCount=rs.RecordCount
for i=1 to BigClassCount
ArrayBigClassID(i)=rs("BigClassID")
ArrayBigClassName(i)=trim(rs("BigClassName"))
rs.MoveNext
next
rs.Close

'rs.Source ="select id,title,addtime,click from news where title like '%" & keyword & "%' or content like '%" & keyword & "%' order by id desc "
if request_BigClassName><"" then
rs.Source="select NewsID,Title,UpdateTime,BigClassName,SmallClassName,SpecialID from News where (BigClassName='" & request_BigClassName &"' and Content like  '%" & keyword & "%' or  title like '%" & keyword & "%') order by NewsID DESC"
else
rs.Source="select NewsID,Title,UpdateTime,BigClassName,SmallClassName,SpecialID from News where  Content like  '%" & keyword & "%'  or title like '%" & keyword & "%' order by NewsID DESC"
end if
rs.Open rs.Source,conn,1,1


rs.PageSize=20
rs.CacheSize = RS.PageSize

for i=1 to rs.PageSize *( page-1)
if not rs.EOF then
rs.MoveNext
end if
next

%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>关键字:<%=keyword%>__搜索__<%=redcaff%></title>
<LINK href=news.css rel=stylesheet>
<link href="../css.css" rel="stylesheet" type="text/css">
</head>

<body topmargin="0">
<!--#include file=include/top.asp -->
<div align="center">
  <table width="778" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="5" background="images/bgimg_left.gif">&nbsp;</td>
      <td><table width="768" height="25" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="f4f4f4">
          <tr> 
            <td width="160">&nbsp;</td>
            <td width="514" height="25"><font color="#000000">当前位置:<a href=./ class=bai1>首页</a>>>搜索>>关键字:</font><%=keyword%></td>
            <td width="95">&nbsp;</td>
          </tr>
        </table>
        <table width="768" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F4f4f4">
          <tr> 
            <td width="160" align="center" valign="top" bgcolor="#f4f4f4"> <table border="0" width="99%" cellspacing="0" cellpadding="0" align="center">
                <tr> 
                  <td width="100%" height="360" align="center" valign="top" bgcolor="#f4f4f4"> 
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="f4f4f4">
                      <tr> 
                        <td width="100%" height="40" align="left" valign="middle" background="images/sousuo.gif"> 
                          <div align="center"></div></td>
                      </tr>
                      <form action=search.asp method=post>
                        <tr> 
                          <td width="100%" height="30" align=center valign="middle" bgcolor="f4f4f4"> 
                            <select size=1 name=WhichClass style=font-size:9pt;position:relative;width:110;height:23>
                              <option value=>请选择搜索类别</option>
                              <option value=0 selected>所有类别</option>
                              <%for i=1 to BigClassCount%>
                              <option value=<%=ArrayBigClassID(i)%>><%=ArrayBigClassName(i)%></option>
                              <%next%>
                            </select>
                          </td>
                        </tr>
                        <tr> 
                          <td width="100%" height="50"  align=center valign="middle" bgcolor="f4f4f4"> 
                            <input type=text name=keyword value="<%=keyword%>" size=14>
                            <br>
                            <input  name=submit1 type=image src=images/serch.gif width="52" height="18"> 
                          </td>
                        </tr>
                      </form>
                    </table>
                  </td>
                </tr>
              </table></td>
            <td width="1" bgcolor="#f4f4f4"></td>
            <td align="center" valign="top" bgcolor="#FFFFFF"> 
              <table width="98%" border="0" align="right" bgcolor="#FFFFFF">
                <tr> 
                  <td width="69%" align="center" valign="top"> <table border="0" cellpadding="3" cellspacing="0" width="100%">
                      <%
Response.Write "<tr><td width=100% >&nbsp;"
if rs.EOF then
Response.Write "<font color=red>抱歉,没有搜索到相关的资料!</font>"
else
Response.Write "共搜索到" & rs.RecordCount & "条相关资料,共"& rs.PageCount &"页,每页"& rs.PageSize &"条(当前第"& Page &"页)"
end if
Response.Write "</td></tr>"


For i=1 to rs.PageSize
if not rs.EOF then
TrString="<tr><td width=100% >&nbsp;<img src=images/arrow.gif><a class=bai1 href='ReadNews.asp?NewsID=" & rs("NewsID") & "&BigClassName=" & rs("BigClassName") & "&SmallClassName=" & rs("SmallClassName") & "&SpecialID=" & rs("SpecialId") & "' target=_blank>" & trim(rs("Title")) & "(" & rs("UpdateTime") & ")</a></td</tr>"
Response.Write TrString

rs.MoveNext
end if

Next
%>
                      <tr> </tr>
                      <tr> 
                        <td width=100% align=center> 
                          <%
url="Result.asp?BigClassName=" & request_BigClassName & "&keyword=" & keyword
					
if page=1 then
Response.Write "首页&nbsp;上一页&nbsp;"					
else
Response.Write "<A class=bai1 href=" & Url & "&page=1>首页</a>&nbsp;<A class=bai1 href=" & Url & "&page=" & page-1& ">上一页</a>&nbsp;"
end if

for i=1 to rs.PageCount
if i=page then
Response.Write "" & i & "&nbsp;"
else
Response.Write "<A class=bai1 href=" & Url & "&page=" & i & ">" & i & "</a> "
end if					
next					
if page=rs.PageCount or page=""& rs.pagecount &"" then
Response.Write "下一页&nbsp;尾页"					
else
Response.Write "<A class=bai1 href=" & Url & "&page=" & page+1 & ">下一页</a>&nbsp;<A class=bai1 href=" & Url & "&page=" & rs.PageCount & ">尾页</a>"
end if					
%>
                        </td>
                      </tr>
                      <tr> 
                        <td width="100%"> </td>
                      </tr>
                      <tr> 
                        <td width="100%"></td>
                      </tr>
                    </table></td>
                </tr>
              </table>
            </td>
          </tr>
        </table></td>
      <td width="5" background="images/bgimg_right.gif">&nbsp;</td>
    </tr>
  </table>
 <table width="780" height="1" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="5" height="1" background="images/bgimg_left.gif"></td>
    <td height="1" bgcolor="cccccc"></td>
    <td width="5" height="1" background="images/bgimg_right.gif"></td>
  </tr>
</table>
  <!--#include file=include/bottom.asp -->
</div>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?