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

📄 list.asp

📁 与asp相关的技术 如数据库和网页设计 很有用的哦
💻 ASP
字号:
<!--#INCLUDE FILE="../../../system/odbc_connection.asp"-->
<%	if session("user_type")<>"T" then
		response.redirect "../../../index.asp"
	end if
%>
<HTML>
	<head>
		<title>资源管理</title>
		<link rel="stylesheet" href="../../../system/all.css">
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
		<script language="JAVASCRIPT">
		<!--
		function Trim(str){
		  while (str !="" && str.charAt(0) == " ") str = str.substring(1,str.length);
		  while (str !="" && str.charAt(str.length-1) == " ") str = str.substring(0,str.length-1);
		  return str;
		}
		function check_Null(){
			if (Trim(document.form1.words.value)==""){
				alert("关键字不能为空!");
				return false;
			}

			return true;
		}


		// -->
		</script>	</head>
<body>
	<%
		dim user_id,user_type,id,subject_name
		user_id=session("user_id")
		user_type=session("user_type")
		'判断应该回到哪一个类别
		if request("id")="" Then
			id=session("subject_id") 'ID从session里取值
			subject_name=session("subject_name")
		else
			id=request("id")  '子类别编号
			subject_name=request("subject_name") '子类别名称
			session("subject_id")=id
			session("subject_name")=subject_name
		end if
		response.write "<h4>" & subject_name & "</h4>"
		%>
		<CENTER>
		<table border="0" width="95%">
		<tr><td>
		<form action="result.asp" method="post" name="form1" onsubmit="javascript: return check_Null();">
			&nbsp&nbsp
			查找关键字<input type="text" name="words" size="15">
			&nbsp查找字段
			<select name="fanwei">
				<option value="ALL">全部</option>
				<option value="file_name">题目</option>
				<option value="author">作者</option>
				<option value="abstract">摘要</option>
				<option value="keywords">关键字</option>
				<option value="magazine">来源</option>
				
			</select>			
			&nbsp查找范围
			<select name="liebie">
				<%
				sql="select * from reference_board where lesson_id='" & session("lesson_id") & "'"
				set rs=db.execute(sql)
				response.write "<option  value='ALL'>全部</option>"
				do while not rs.eof
					response.write "<option  value='"& rs("id") & "'>"& rs("subject_name") &"</option>"
					rs.movenext
				loop
				response.write "<option  value='0'>其它</option>"
				%>
			</select>
			&nbsp&nbsp<input type="submit" value=" 查找 " class="buttonstyle">
		</form>
		</td><td>
		<form action="add_form.asp" method="post" name="form2">
			&nbsp&nbsp&nbsp<input type="submit" value="添加新资源" class="buttonstyle">
		</form>
		</td></tr>
		</table>

		<p>
		<TABLE border="0" bordercolor="#8800FF" width="95%" cellspacing="2">
		<tr align=center>
			<td width=5%>序号</td>
			<TD width=35%>名称</TD>
			<TD width=30%>摘要</TD>
			<TD width=10%>点击/评论</TD>
			<TD width=10%>时间</TD>
			<TD width=10%>操作</TD>
		</tr>

		<%
		'下面开始正式查询

		SQL="SELECT  * FROM reference"
		SQL=SQL + " WHERE subject_id=" & id
		sql=sql + " and lesson_id='" & session("lesson_id") & "'"
		SQL=SQL + " order by id desc"

		
		'如果第一次或选择了排行榜,就选择这个
		if id="ALL" then
			sql="select * from reference"
			SQL=SQL + " WHERE lesson_id='" & session("lesson_id") & "'"
			sql=sql + " order by id desc"
		end if
		
		'为分页显示做准备,所以键盘指针不一样。
		Set rs=Server.CreateObject("ADODB.Recordset")
		rs.Open sql,db,1
		
		'如果数据库里有数据,开始显示
		if not rs.bof or not rs.eof then

		dim page_size
		dim page_no                             	
		dim page_total  
		page_size=15  '每页显示15条记录
		'如果第一次打开,则page_no为1,否则由传回的参数决定
		if request.querystring("id")<>"" then
			session("page_no")=""
		end if
		if Request.QueryString("page_no")="" then   
			if session("page_no")="" then
				page_no=1 
			else
				page_no=session("page_no")
			end if
		else
			page_no=Cint(Request.QueryString ("page_no"))  '用Cint将字符串变为整数
		end if
		session("page_no")=page_no

		rs.PageSize=page_size
		page_total=rs.PageCount
		rs.AbsolutePage=page_no
		'下面一段显示当前页的所有记录
		Dim IJ
		IJ=page_size                          '该变量用来控制显示当前页记录
		i=page_size*(page_no-1)  
		Do While Not rs.Eof And IJ>0            '循环直到当前页结束或文件结尾
			i=i+1    '序号变量
			IJ=IJ-1    '循环变量
		%>
			<TR bgcolor=#FFFFCC align="center">
				<td align=center width=5%><%=i%>
				<TD width=35%><a href="particular.asp?thename=<%=rs("id")%>&thename2=<%=id%>&thename3=<%=subject_name%>"><%=RS("file_name")%></a></TD>
				<TD width=10%><%=left(RS("abstract"),40)%></TD>
				<TD width=10%><%=RS("hits")%>/<%=RS("childs")%></TD>
				<TD width=10%><%=RS("submit_date")%></TD>

				<TD width=10%>
				<%'if rs("writer_id")=user_id  then%>
					<a href="delete.asp?thename=<%=rs("id")%>&thename2=<%=id%>&thename3=<%=subject_name%>">删除</a>
				<%'end if%>
			</TR>
			<%
			RS.MOVENEXT 
			LOOP 
			%>
		</TABLE>
	<%
	'输出有关页数信息,从1到总页数循环,如不是当前页,就加上超链接
	response.write "<p>请选择显示数据页&nbsp&nbsp&nbsp"
	For I=1 To page_total                        
		If I=page_no Then                        
			Response.Write "<font color='red'>" & I & "</font>&nbsp"
		Else
			Response.Write "<a href='list.asp?page_no=" & I & "'>" & I & "</a>&nbsp"
		End If
	Next

	end if
	'关闭对象
	%>
		</CENTER>
		</body>
</HTML>

⌨️ 快捷键说明

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