asp在最近3天的新闻后加new图标的问题!
代码如下,请高手帮忙改改,急用!<!--#includefile=include/conn.asp--><!--#includefile=include/config.a...
代码如下,请高手帮忙改改,急用!
<!--#include file=include/conn.asp -->
<!--#include file=include/config.asp -->
<!--#include file=include/function.asp -->
<!--#include file="admin/char.inc"-->
<%
dim shu,news,bigclassid,smallclassid,specialid,order,time,path,click,title
bigclassid=checkstr(request.querystring("bigclassid"))
typeid=checkstr(request.querystring("typeid"))
smallclassid=checkstr(request.querystring("smallclassid"))
specialid=checkstr(request.querystring("specialid"))
shu=checkstr(request.querystring("shu"))
order=checkstr(request("order"))
time=checkstr(request.querystring("time"))
title=checkstr(request.querystring("title"))
click=checkstr(request.querystring("click"))
Path = "./"
if shu<>"" then '显示数目,不加为10
ss=shu
else
ss=10
end if
if order="click" then '排序方式,click为按点击率
oo="click"
else
oo="newsid"
end if
if time="0" then '显示时间,0为不显示
tt=0
else
tt=1
end if
if click="0" then '显示点击数,0为不显示
cc=0
else
cc=1
end if
if title<>"" then '显示数目,不加为10,……为什么添了6反而只显示了时间?
nn=title
else
nn=16 '显示标题中文汉字数目,
end if
if typeid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where typeid=cint("&typeid&") and checkked=1 order by "&oo&" desc")
else
if bigclassid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where bigclassid=cint("&bigclassid&") and checkked=1 order by "&oo&" desc")
else
if smallclassid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where smallclassid=cint("&smallclassid&") and checkked=1 order by "&oo&" desc")
else
if specialid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where specialid=cint("&specialid&") and checkked=1 order by "&oo&" desc")
else
set rs=conn.execute("SELECT top "&ss&" * FROM news where checkked=1 order by "&oo&" desc")
end if
end if
end if
end if
if rs.eof and rs.bof then %>
document.write('没有');
<% else
do while not rs.eof
title=trim(rs("title"))
title=replace(title,"<br>","")
if strcomp(left(title,nn),title)<0 then
%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%else%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%
end if
rs.movenext
loop
end if
Rs.Close
set Rs=nothing
%>
andy80129你好!我也是用datediff函数试了好多次,可是不行,主页的布局都乱了,可能是代码加的地方不对,你再帮忙看看,应该加在哪。 展开
<!--#include file=include/conn.asp -->
<!--#include file=include/config.asp -->
<!--#include file=include/function.asp -->
<!--#include file="admin/char.inc"-->
<%
dim shu,news,bigclassid,smallclassid,specialid,order,time,path,click,title
bigclassid=checkstr(request.querystring("bigclassid"))
typeid=checkstr(request.querystring("typeid"))
smallclassid=checkstr(request.querystring("smallclassid"))
specialid=checkstr(request.querystring("specialid"))
shu=checkstr(request.querystring("shu"))
order=checkstr(request("order"))
time=checkstr(request.querystring("time"))
title=checkstr(request.querystring("title"))
click=checkstr(request.querystring("click"))
Path = "./"
if shu<>"" then '显示数目,不加为10
ss=shu
else
ss=10
end if
if order="click" then '排序方式,click为按点击率
oo="click"
else
oo="newsid"
end if
if time="0" then '显示时间,0为不显示
tt=0
else
tt=1
end if
if click="0" then '显示点击数,0为不显示
cc=0
else
cc=1
end if
if title<>"" then '显示数目,不加为10,……为什么添了6反而只显示了时间?
nn=title
else
nn=16 '显示标题中文汉字数目,
end if
if typeid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where typeid=cint("&typeid&") and checkked=1 order by "&oo&" desc")
else
if bigclassid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where bigclassid=cint("&bigclassid&") and checkked=1 order by "&oo&" desc")
else
if smallclassid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where smallclassid=cint("&smallclassid&") and checkked=1 order by "&oo&" desc")
else
if specialid<>"" then
set rs=conn.execute("SELECT top "&ss&" * FROM news where specialid=cint("&specialid&") and checkked=1 order by "&oo&" desc")
else
set rs=conn.execute("SELECT top "&ss&" * FROM news where checkked=1 order by "&oo&" desc")
end if
end if
end if
end if
if rs.eof and rs.bof then %>
document.write('没有');
<% else
do while not rs.eof
title=trim(rs("title"))
title=replace(title,"<br>","")
if strcomp(left(title,nn),title)<0 then
%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%else%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%
end if
rs.movenext
loop
end if
Rs.Close
set Rs=nothing
%>
andy80129你好!我也是用datediff函数试了好多次,可是不行,主页的布局都乱了,可能是代码加的地方不对,你再帮忙看看,应该加在哪。 展开
3个回答
展开全部
if strcomp(left(title,nn),title)<0 then
%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%else%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%
end if
'======关键在这里了======
if datediff("d",rs("updatetime"),now())<=3 then
%>
'response.Write"<img src='images/new.gif' alt='最新发布' border=0>"
document.write("<img src='images/new.gif' alt='最新发布' border=0>)"
<% end if
'=======================
rs.movenext
loop
end if
Rs.Close
set Rs=nothing
%>
%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%else%>
document.write('<font class=3> - <A href="<%=path%>ReadNews.asp?NewsID=<%=rs("NewsID")%>" title="<%=title%>" target="_blank"><%=left(title,nn)%></A><%if tt=1 then%><FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%></font>');
<%
end if
'======关键在这里了======
if datediff("d",rs("updatetime"),now())<=3 then
%>
'response.Write"<img src='images/new.gif' alt='最新发布' border=0>"
document.write("<img src='images/new.gif' alt='最新发布' border=0>)"
<% end if
'=======================
rs.movenext
loop
end if
Rs.Close
set Rs=nothing
%>
展开全部
把如下代码加到<FONT color="#666666">[<%=month(rs("updatetime"))%>-<%=day(rs("updatetime"))%>]</FONT><br><%end if%>把代码加到这里</font>');
<%If CDate(DateAdd("d",3,Cdate(rs("updatetime")))) < Now() Then%>
<%n="NEW"%>
<%Else%>
<%n=""%>
<%End If%>
<%=n%>
<%If CDate(DateAdd("d",3,Cdate(rs("updatetime")))) < Now() Then%>
<%n="NEW"%>
<%Else%>
<%n=""%>
<%End If%>
<%=n%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询