?? default.asp
字號:
<!--#include File="ConnDB.asp"-->
<html>
<head>
<title>查看新聞</title>
<meta HTTP-EQUIV="Content-topic" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet">
<script language="JavaScript">
function newwin(url) {
var wth=window.screen.width;
var hth=window.screen.heigth;
var lefth,topth;
if(wth==1024)
{
hth=500;
lefth =147;
wth=550;
topth=44;
}
else if(wth==800)
{
hth=500;
lefth =35;
wth=500;
topth=10;
}
else
{
hth=500;
wth=500;
}
var oth="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left="+lefth+",top="+topth;
oth = oth+",width="+wth+",height="+hth ;
var newwin=window.open(url,"newwin",oth);
newwin.focus();
return false;
}
</script>
<% dim rs, sql,rsCate
'定義Recordset對象,用于保存新聞類別記錄集
Set rs = Server.CreateObject("ADODB.Recordset")
set rsCate = Server.CreateObject("ADODB.Recordset")
%>
</head>
<body bgcolor=#ffffff>
<div align=center><strong><font color="blue" size="3">新 聞 欄 目</font></strong><br><br>
<%
'=====顯示所有新聞類別供點擊,點擊不同類別顯示該類別的新聞=====
'按順序讀取所有新聞類別,保存在記錄集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類別編號
%>
<a href="#a<%=cid%>"><font style='TEXT-DECORATION: none;color:black'><%=stitle%></font></a> |
<%
rsCate.MoveNext
Loop
%>
<a href='search.asp'><font color=red>新聞查詢</font></a>
| <a href="index.asp"><font color=red style='TEXT-DECORATION: none'>新聞管理</font></a>
</div>
<table align="center" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="*" valign="TOP">
<%
'將指針移至開始位置,分別顯示每個分類中的新聞
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 "<table width='100%' cellspacing=1 cellpadding=2><tr>"
'顯示新聞類別,并設置書簽
Response.Write "<td bgcolor=#ceceff><a name=""a"&cid&"""></a> == "
'顯示新聞類別標題
Response.Write stitle + " ==</td></tr>"
'生成另一個表格,用于顯示新聞標題
Response.Write"<table width='100%' border=0 cellspacing=0 cellpadding=0>"
'按提交時間的降序顯示新聞標題
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
'只顯示5條新聞
If cnt < 6 Then
Dim ndate
ndate = DateAdd("d",-3,date())
'顯示新聞標題及鏈接,查看新聞的腳本文件為NewsView.asp
Response.Write "<tr><td width='50%'><a onClick='return newwin(this.href);' href='NewsView.asp?id=" + cstr(rs("id")) + "'>" + rs("Title") +""
'如果新聞中有圖片,則在標題中顯示(附圖)
If rs("Attpic") Then Response.Write "(附圖)" End If
Response.Write "</a>"
'3天內新聞標記new圖片
If datediff("d", rs("Posttime"), ndate+time()) <= 0 Then
Response.Write "<img SRC='pic/new.gif' ALT='最新的新聞!' border=0></td>"
End If
'顯示新聞提交的時間
Response.Write "<td width='20%'>(" + CStr(rs("Posttime")) + ")</td></tr>"
End If
rs.MoveNext
Loop
Response.Write"</table>"
'設置返回頂部鏈接,跳轉到書簽#top
Response.Write "<p align=right><a href=""#top"">返回頂部</a> "
'生成“更多新聞”鏈接,查看指定類別所有新聞的腳本為Category.asp
Response.Write "<a target='_self' href='Category.asp?flag=" + CStr(cid) + "'>更多新聞...</a></p>"
Response.Write "</td></tr></table></td></table>"
rs.Close
rsCate.MoveNext
loop
%>
</td></table>
<%
'釋放資源
Set rs = nothing
Set rsCate = nothing
%>
<p align=center><a href="javascript:close()">[關閉]</a>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -