asp.net里实现两三天内的新闻后面有new的图标的代码怎么实现 我是菜鸟中菜鸟 请各位大侠写易懂些 万分感谢
2个回答
展开全部
这我不知道了 我用千博后台系统的 他帮我自动的设定的
<%
function News(SortPath)
dim rs,sql,NewsName,NewFlag
set rs = server.createobject("adodb.recordset")
sql="select top 4 * from Qianbo_News where ViewFlag and Instr(SortPath,'"&SortPath&"')>0 order by id desc" '数据库 ' top 5 限制标题5条...
rs.open sql,conn,1,1
if rs.eof then
Response.Write "<tr>"&VbCrLf
Response.Write "<td align=""center"" height=""28"">暂无相关信息</td>"&VbCrLf
Response.Write "</tr>"&VbCrLf
else
do while not rs.eof
if now()-rs("AddTime")<=2 then
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag=" <img src=""Images/new.gif"" valign=""center"">"
else
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag=""
end If
If ISHTML = 1 Then
AutoLink = ""&NewName&""&Separated&""&rs("ID")&"."&HTMLName&"" '静态链接
Else
AutoLink = "NewsView.asp?ID="&rs("id")&"" '动态链接
End If
Response.Write "<tr>"&VbCrLf
Response.Write " <td height=""25""><table width=""345"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"&VbCrLf '表格整体长度
Response.Write "<tr>"&VbCrLf
Response.Write "<td width=""265"" align=""left"" style=""background:url(images/bg5.gif) repeat-x left bottom;""><img src=""images/arr2.gif"" width=""3"" height=""5"" align=""absmiddle"" /> <a href="""&AutoLink&""">"&NewsName&"</a>"&NewFlag&"</td>"&VbCrLf '标题格式
Response.Write "<td width=""80"" align=""center"" style=""font-size:12px; color:#999999; background:url(images/bg5.gif) repeat-x left bottom;""><img src=""images/clock.gif"" width=""7"" height=""7"" valign=""center"" /> "&FormatDate(rs("Addtime"),14)&"</td>"&VbCrLf '时间格式
Response.Write "</tr>"&VbCrLf
Response.Write "</table></td>"&VbCrLf
Response.Write "</tr>"&VbCrLf
rs.movenext
loop
end if
rs.close
set rs=nothing
end Function%>
我只能帮你这么多 我也是菜鸟 - -. 而且才是ASP
if now()-rs("AddTime")<=2 then '当前时间减去新闻时间小于等于2的话 链接第一个
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag=" <img src=""Images/new.gif"" valign=""center"">" '这是new图片
else '否则就链接第二个
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag="" '这没new图片
end If
<%
function News(SortPath)
dim rs,sql,NewsName,NewFlag
set rs = server.createobject("adodb.recordset")
sql="select top 4 * from Qianbo_News where ViewFlag and Instr(SortPath,'"&SortPath&"')>0 order by id desc" '数据库 ' top 5 限制标题5条...
rs.open sql,conn,1,1
if rs.eof then
Response.Write "<tr>"&VbCrLf
Response.Write "<td align=""center"" height=""28"">暂无相关信息</td>"&VbCrLf
Response.Write "</tr>"&VbCrLf
else
do while not rs.eof
if now()-rs("AddTime")<=2 then
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag=" <img src=""Images/new.gif"" valign=""center"">"
else
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag=""
end If
If ISHTML = 1 Then
AutoLink = ""&NewName&""&Separated&""&rs("ID")&"."&HTMLName&"" '静态链接
Else
AutoLink = "NewsView.asp?ID="&rs("id")&"" '动态链接
End If
Response.Write "<tr>"&VbCrLf
Response.Write " <td height=""25""><table width=""345"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">"&VbCrLf '表格整体长度
Response.Write "<tr>"&VbCrLf
Response.Write "<td width=""265"" align=""left"" style=""background:url(images/bg5.gif) repeat-x left bottom;""><img src=""images/arr2.gif"" width=""3"" height=""5"" align=""absmiddle"" /> <a href="""&AutoLink&""">"&NewsName&"</a>"&NewFlag&"</td>"&VbCrLf '标题格式
Response.Write "<td width=""80"" align=""center"" style=""font-size:12px; color:#999999; background:url(images/bg5.gif) repeat-x left bottom;""><img src=""images/clock.gif"" width=""7"" height=""7"" valign=""center"" /> "&FormatDate(rs("Addtime"),14)&"</td>"&VbCrLf '时间格式
Response.Write "</tr>"&VbCrLf
Response.Write "</table></td>"&VbCrLf
Response.Write "</tr>"&VbCrLf
rs.movenext
loop
end if
rs.close
set rs=nothing
end Function%>
我只能帮你这么多 我也是菜鸟 - -. 而且才是ASP
if now()-rs("AddTime")<=2 then '当前时间减去新闻时间小于等于2的话 链接第一个
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag=" <img src=""Images/new.gif"" valign=""center"">" '这是new图片
else '否则就链接第二个
NewsName=StrLeft(rs("NewsName"),32) '标题字符限制
NewFlag="" '这没new图片
end If
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询