<% dim rs, sql,rsCate '定义Recordset对象,用于保存文章类别记录集 Set rs = Server.CreateObject("ADODB.Recordset") set rsCate = Server.CreateObject("ADODB.Recordset") %>



<% '=====显示所有文章类别供点击,点击不同类别显示该类别的文章===== '按顺序读取所有文章类别,保存在记录集rsCate中 sql = "SELECT * FROM Category ORDER BY CateId" Set rsCate = conn.Execute(sql) '显示所有文章类别链接 Do While Not rsCate.EOF stitle = rsCate("CateName") cid = rsCate("CateId") '每个文章类别标题被定义为一个书签,名为 #a类别编号 %> <%=stitle%> | <% rsCate.MoveNext Loop %> 公告查询公告管理 [返回主页]

<% '将指针移至开始位置,分别显示每个分类中的文章 If rsCate.BOF = False Then rsCate.MoveFirst End If '依次显示每个文章类别中最新的10条文章 DO WHILE Not rsCate.EOF stitle = rsCate("CateName") cid = rsCate("CateId") '变量cnt用来记录 cnt = 0 '生成表格 Response.Write "" '显示文章类别,并设置书签? Response.Write "" '生成另一个表格,用于显示文章标题 Response.Write"

 == " '显示文章类别标题 Response.Write stitle + " ==

" '按提交时间的降序显示文章标题 sql = "SELECT * FROM News WHERE CateId=" & cid & " ORDER BY Posttime DESC" rs.Open sql, conn, 1, 1 DO WHILE Not rs.EOF '计数 cnt = cnt + 1 '只显示10条文章 If cnt < 21 Then Dim ndate ndate = DateAdd("d",-3,date()) '显示文章标题及链接,查看文章的脚本文件为NewsView.asp Response.Write "" End If '显示文章发布单位 Response.Write "" '显示文章提交的时间 Response.Write "" End If rs.MoveNext Loop Response.Write"
" + rs("Title") +"" '如果文章中有图片,则在标题中显示(附图) If rs("Attpic") Then Response.Write "(附图)" End If Response.Write "" '3天内文章标记new图片 If datediff("d", rs("Posttime"), ndate+time()) <= 0 Then Response.Write "最新的公告!(" + rs("weiyuanhuiname") + ")(" + CStr(rs("Posttime")) + ")
" '设置返回顶部链接,跳转到书签#top Response.Write "

返回顶部   " '生成“更多文章”链接,查看指定类别所有文章的脚本为Category.asp Response.Write "更多公告...

" Response.Write "
" rs.Close rsCate.MoveNext loop %> <% '释放资源 Set rs = nothing Set rsCate = nothing %>

[返回主页]