⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchresult.asp

📁 一个网上人才管理系统
💻 ASP
字号:
<!--#include File="ConnDB.asp"-->

<html><head>
<link rel="stylesheet" href="style.css">
<script LANGUAGE="javascript">
// 打开新窗口
function newwin(url) {
var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=650,height=550")
newwin.focus()
return false;
}
</script>
</head>
<body vlink="#1155AA" bgcolor="#FFFFFF"><center>
<%
  '根据用户名读取用户姓名
  Function GetUserName(UserId)
    Dim RsUser,sql
    Set RsUser = Server.CreateObject("ADODB.RecordSet")
    sql= "SELECT * FROM Users WHERE UserName='" & Trim(UserId) & "'"
    Set rsUser = Conn.Execute(sql)
    If NOT rsUser.EOF Then
      GetUserName = rsUser("Ename")
    Else
      GetUserName = "无名"
    End If
  End Function
%>
<%
  ' 提取发布时间查询范围
  sDate = Request("sdate")
  eDate = Request("edate")
  ' 根据时间字段设置查询语句,需要把时间字符串转换为日期型
  If Len(sDate)>0 And Len(eDate)>0  Then
	strSqlPTime = " WHERE PostTime>='" & sDate & "'"
	strSqlPTime = strSqlPTime & " And PostTime<='" & eDate & "'"
  ElseIf Len(sDate)>0 And Len(eDate)=0 Then
	strSqlPTime = " WHERE PostTime>='" & sDate & "'"
  ElseIf Len(sDate)=0 And  Len(eDate)>0 Then
	strSqlPTime = " WHERE PostTime<='" & eDate & "'"
  End If
  ' 取得查询模式(精确查询或模糊查询),参见search.asp中的定义
  searchcontent1 = Request("searchcontent")
  fanwei = Request("fanwei")
  If fanwei ="all" Then '精确查询
	searchcontent = searchcontent1
  Else  '模糊查询
	searchcontent = "%" & searchcontent1 & "%"
  End If
  ' 取得查询范围值
  searchfanwei = Request("D1")
  If searchfanwei="title" Then '只在新闻标题中查询
	Response.Write "<h4><font color=#7966C6>按 信息标题 查询的结果</font></h4><br>"
	strSQL = " Title LIKE '" & searchcontent & "' ORDER BY PostTime DESC"
  ElseIf searchfanwe="content" Then  '只在新闻内容中查询
	Response.Write "<h4><font color=#7966C6>按 信息内容 查询的结果</font></h4><br>"
	strSQL = " Content LIKE '" & searchcontent1 & "' ORDER BY PostTime DESC"
  End If
  '合并查询条件
  If Len(strSqlPTime)=0 Then
 	strSQL = " WHERE " & strSQL
  Else
	strSQL = strSqlPTime & " And " & strSQL
  End If

  '记录查找到的新闻序号
  Dim ncnt
  ncnt = 0
  '输出表格
  Response.Write "<table width='100%'>"
  Response.Write "<tr>"
  Response.Write "<td align=middle width='10%'><b>序号</b></td>"
  Response.Write "<td align=left width='30%'><b>信息标题</b></td>"
  Response.Write "<td align=middle width='14%'><b>所属类别</b></td>"
  Response.Write "<td align=middle width='10%'><b>内容长度</b></td>"
  Response.Write "<td align=middle width='16%'><b>提交人</b></td>"
  Response.Write "<td align=middle width='20%'><b>提交时间</b></td>"
  Response.Write "</tr>"
	
  Dim rsSearch,rsCate
  Set rsSearch= Server.CreateObject("ADODB.RecordSet")
  Set rsCate = Server.CreateObject("ADODB.RecordSet")
  '生成查询语句
  strSQL = "SELECT * FROM News " & strSQL
  'Response.Write "sql :"& strSQL
  rsSearch.Open strSQL, Conn, 1, 3
  '依次处理查询结果
  Do While Not rsSearch.EOF
    ncnt = ncnt + 1
    Response.Write "<tr bgColor=Lavender style='COLOR:Purple;'>"
    Response.Write "<td align=middle>"&ncnt&"</td>"
    '输出新闻标题及链接
    Response.Write "<td><a href=NewsView.asp?id="&rsSearch("Id")&" onClick='return newwin(this.href)'>"&rsSearch("Title")&"</a>"
    ' 判断是否有图片
    If rsSearch("attpic") Then
      Response.Write "(附图)"
    End If
    Response.Write "</td>"
    ' 取得信息分类名称
    sql = "SELECT * FROM Category WHERE CateId=" & rsSearch("CateId")
    Set rsCate = Conn.Execute(sql)
    If NOT rsCate.EOF Then
      Response.Write "<td align=middle>"&rsCate("CateName")&"</td>"
    End If
    ' 计算内容大小
    If rsSearch("Content")="--" Then
      nlength=0
    Else
      nlength = Len(rsSearch("Content"))
      ' 输出内容大小、提交人姓名
      Response.Write "<td align=middle>"&nlength&"&nbsp;Bytes</td>"
      ' 显示提交人姓名
      Response.Write "<td align=middle>"&GetUserName(rsSearch("Poster"))&"</td>"
      ' 显示提交时间
      Response.Write "<td align=middle>"&rsSearch("PostTime")&"</td>"
      Response.Write "</tr>"
    End If
    rsSearch.MoveNext()
  LOOP
  Response.Write "</table>"
  Set rsSearch = Nothing
  Set rsCate = Nothing
  Set Conn = Nothing
%>
</center>
<p align="center">
<input type="button" value=" 返 回 " LANGUAGE =javascript onclick="history.back()">
</p>
</body></html>

⌨️ 快捷键说明

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