关于ASP循环语句的问题

来源:百度知道 编辑:UC知道 时间:2024/05/03 09:59:32
怎样才能让指针从最后一个记录向上查询 现在的语句每次只显示头三个记录 后面新加的都不显示 我想显示最新的三个

<%
do while (not rs_showcat.eof)
if rs_showcat("key") <> "" and iii<3 then
%>
<td><a href="product_list.asp?bid=<%=rs_showcat("bid")%>"><img class=img_home border=0 src="<%=rs_showcat("key")%>"></a></td>
<%
iii = iii + 1
end if
rs_showcat.movenext
loop
%>

写SQL语句的时候加上Order by date desc,假如有个时间字段date。另外你想显示三条不用使这种方法,在SQL语句中能控制:
SELECT TOP 3 FROM table ORDER BY date DESC;