日期:2014-05-17  浏览次数:20822 次

在线等~~一个简单的读取数据问题!!!!!
我一个JS调用的文件~现在加了个文章 "置顶 "的..数据库dz列有数据为1时就说明置顶..但是这个JS文件我该如何改,它才能显示置顶的文章在上面呢??谢谢了~


document.write( " <table   cellSpacing=0   cellPadding=0   width=auto   border=0   bgColor=#FFFFFF   align=center> ")
<%
d_num=request.querystring( "n ")
set   rs=server.createobject( "adodb.recordset ")
sql= "Select   top   "&d_num& "   *   From   softgwa   order   by   id   desc "
rs.open   sql,conn,1,1
%>
document.write( " <tr> ")
<%
i=1
while   not   rs.eof
%>
document.write( " <td   width=auto   height=23   align=center> ")
<%
id=rs( "id ")
url1=rs( "url1 ")
vest_m=rs( "vest_m ")
vest_s=rs( "vest_s ")
title=rs( "title ")
if   instr(rs( "url1 "), "http:// ")   then  
url11= " "&url1& " "
else
url11= "/shop/ "&url1& " "
end   if
%>
document.write( " <td> ")
document.write( " <a   href= '/shop/produce.asp?mclass= <%=rs( "vest_m ")%> &sclass= <%=rs( "vest_s ")%> &id= <%=rs( "id ")%> '   target= '_blank '> <img   title= <%=rs( "title ")%>   src= <%=url11%>   height=64   width=80   border=0> </a>   ")
document.writeln( " <span   style=\ "font-size:   9pt\ "> ")
document.write( " <%=left(Rs( "title "),5)%> </td> ")
<%
if   (i   mod   4)=0   then
%>
document.write( " </tr> ")
<%
end   if
rs.movenext
i=i+1
wend
'end   if
rs.close
set   rs=nothing
conn.close
set   conn=nothing
%>
document.write( " </table> ")

------解决方案--------------------
sql= "Select top "&d_num& " * From softgwa order by id desc "
改为:
sql= "Select top "&d_num& " * From softgwa where dz=1 order by id desc "
------解决方案--------------------
如果dz为数字型且默认值为零的情况下:
sql= "Select top "&d_num& " * From softgwa order by dz desc,id desc "
……
document.write( " <%if rs( "dz ")=1 then%> 置顶 <%end if%> <%=left(Rs( "title "),5)%> </td> ")