日本高中教育:网页高手帮忙!!急.........!!1

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 06:11:00
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conn_news.asp" -->
<% dim s
s=request("s")
%>
<%
Dim rs__MMColParam
rs__MMColParam = "1"
If (Request.QueryString("t_id") <> "") Then
rs__MMColParam = Request.QueryString("t_id")
End If
%>
<%
Dim rs
Dim rs_numRows

Set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = MM_conn_news_STRING
rs.Source = "SELECT * FROM t_news WHERE n_tid = " + Replace(rs__MMColParam, "'", "''") + " and n_check = true ORDER BY n_id DESC"
rs.CursorType = 0
rs.CursorLocation = 2
rs.LockType = 1
rs.Open()

rs_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = s
Repeat1__index = 0
rs_numRows = rs_numRows + Repeat1__numRows
%>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
function DoDateTime(str, nNamedFormat, nLCID)
dim strRet
dim nOldLCID

strRet = str
If (nLCID > -1) Then
oldLCID = Session.LCID
End If

On Error Resume Next

If (nLCID > -1) Then
Session.LCID = nLCID
End If

If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
strRet = FormatDateTime(str, nNamedFormat)
End If

If (nLCID > -1) Then
Session.LCID = oldLCID
End If

DoDateTime = strRet
End Function
</SCRIPT>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs.EOF))
%>
document.write('<table width="98%" border="0" cellspacing="0" cellpadding="0"><tr> <td width="5%" align="center" height="16"></td><td><a href="news/<%=(rs.Fields.Item("n_tid").Value)%>/<%=(rs.Fields.Item("n_fname").Value)%>" target="_blank"><%=(rs.Fields.Item("n_title").Value)%></a></td><td width="20%"><%= DoDateTime((rs.Fields.Item("n_date").Value), 4, 1033) %></td></tr></table>');
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs.MoveNext()
Wend
%>
<%
rs.Close()
Set rs = Nothing
%>
我想在显示新闻标题时候,进行判断如果是当天就显示new,如果不是当天的就显示日期.我该如何书写代码,怎么样加入到上面中啊!!

在代码里搜索这句:

<%= DoDateTime((rs.Fields.Item("n_date").Value), 4, 1033) %>

替换为:

<%
yourDate=(rs.Fields.Item("n_date").Value)
myDate=date()

if yourDate=myDate then
write("new!")
else
write(DoDateTime(yourDate,4, 1033))
end if
%>

//但前提要保证你的数据库里保存的日期是 XXXX-XX-XX格式的。。。

很简单:

if rs.Fields.Item("n_date").Value = date then
response.write("new\n");
else
response.write(rs.Fields.Item("n_date").Value+"\n");
end

有问题再联系我finger99@163.com

记得加分啊!:)

最简单的办法就是在数据库中加入“上传时间”字段,然后用

<% IF RS("上传时间")=DATE() THEN %>
NEW
<% ELSE %>
<% =RS("上传时间") %>
<% END IF %>

不用那么多话.