请帮忙修改一段网页代码

来源:百度知道 编辑:UC知道 时间:2024/06/21 19:50:11
一下代码是把刚发的文章标题排到最后,如何修改才能把刚发的文章排到最前呢?
请高手帮忙修改,谢谢!

<td align=center style='line-height:<%=moreline%>pt'>
<%
sql= "select * from news where title<>'' and sh=1 "

if lm2<>"0" then
sql=sql&" and (lm='"&lm&"' or lm2='"&lm2&"') "
end if
%>
</td><td align=left style='line-height:<%=moreline%>pt'><%if lmname="1" then Response.Write"<td width='100%'>"
Response.Write"<TABLE width=95% border=0 align='center' cellPadding=0 cellSpacing=0><TBODY><TR><TD colspan='9'><IMG height=1 src='3.files/trans.gif' width=50></TD></TR><TR><TD width='1'><IMG height=21 src='images/trans.gif' width=1></TD><TD width='5' align=middle style='PADDING-TOP

你从数据库里查出来的时候不能按时间降序吗?

找一下你的数据库里的字段,
看有没有时间字段,
如果有就改一下.
sql= "select * from news where title<>'' and sh=1 "
if lm2<>"0" then
sql=sql&" and (lm='"&lm&"' or lm2='"&lm2&"') "
end if
在这下面加上
sql=sql&" order by 时间或日期字段 desc"

注意一定要有desc,
这是指明降序的,
也就是从大到小。

下面是给你改好的.拿去用用吧.
<td align=center style='line-height:<%=moreline%>pt'>
<%
sql= "select * from news where title<>'' and sh=1 "

if lm2<>"0" then
sql=sql&" and (lm='"&lm&"' or lm2='"&lm2&"') "
end if
sql=sql&"order by id desc"
%>
</td><td align=left style='line-height:<%=moreline%>pt'><%if lmname="1" then Response.Write"<td width='100%'&