这段代码怎样 实现最近七天添加的ASP新闻标题后面加new图片代码?_
<%news_type="企业新闻"sql="selecttop5*fromnewswherenews_class_id=28orderbynews_iddesc"set...
<%
news_type ="企业新闻"
sql="select top 5 * from news where news_class_id=28 order by news_id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
%>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height=5></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle"> <a href="ShowNews.asp?news_id=<%=rs("news_id")%>"><span class="width"><%=rs("news_title")%></span></a>
</td>
</tr>
</table>
<%rs.movenext
loop
if rs.recordcount>0 then
%>
<%
end if
rs.close
set rs=nothing
end if
%> 展开
news_type ="企业新闻"
sql="select top 5 * from news where news_class_id=28 order by news_id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
%>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height=5></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle"> <a href="ShowNews.asp?news_id=<%=rs("news_id")%>"><span class="width"><%=rs("news_title")%></span></a>
</td>
</tr>
</table>
<%rs.movenext
loop
if rs.recordcount>0 then
%>
<%
end if
rs.close
set rs=nothing
end if
%> 展开
1个回答
展开全部
假定你的数据表中新闻的录入时间字段名为news_time,以及new图片名为new.gif,那么:
<%
news_type ="企业新闻"
sql="select top 5 * from news where news_class_id=28 order by news_id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
%>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height=5></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle"> <a href="ShowNews.asp?news_id=<%=rs("news_id")%>"><span class="width"><%=rs("news_title")%></span></a><%
if now-rs("news_time")<7 then
%><img src="new.gif"><%
end if
%></td>
</tr>
</table>
<%rs.movenext
loop
if rs.recordcount>0 then
%>
<%
end if
rs.close
set rs=nothing
end if
%>
<%
news_type ="企业新闻"
sql="select top 5 * from news where news_class_id=28 order by news_id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
%>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height=5></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle"> <a href="ShowNews.asp?news_id=<%=rs("news_id")%>"><span class="width"><%=rs("news_title")%></span></a><%
if now-rs("news_time")<7 then
%><img src="new.gif"><%
end if
%></td>
</tr>
</table>
<%rs.movenext
loop
if rs.recordcount>0 then
%>
<%
end if
rs.close
set rs=nothing
end if
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询