注册 登录
编程论坛 ASP技术论坛

网站判断问题

sydpoechang 发布于 2008-01-29 12:42, 1302 次点击
现在有十个数据进行排行
1、2名前面显示1、2名的图片
3、4名前面显示3、4名的图片以此类退
求这样的代码
谢谢了
10 回复
#2
flynet2008-01-29 13:19
按什么条件排了?
#3
sydpoechang2008-01-29 13:43
按照发帖数
#4
flynet2008-01-29 14:13
总有个字段记录他们的发帖数吧? 按照发帖数 desc 排序 就好了啊?循环显示例子:user 表  counts 字段记录发帖数
其他省略
 sql=“select * from user order by counts desc”
rs.open sql,conn,1,1
i=1
do while not rs.eof
if i=1 or i=2 then
response.write("<img src='第1\2的图片'/>"&rs("username")&"<br>")
elseif i=3 or i=4 then
response.write("<img src='第3\4的图片'/>"&rs("username")&"<br>")
elseif i=5 or i=6 then
response.write("<img src='第5\6的图片'/>"&rs("username")&"<br>")
i=i+1
end if
rs.movenext
loop
#5
sydpoechang2008-01-29 14:46
<%
              Set rs=Server.CreateObject("ADODB.RecordSet")
              sql="select top 10 * from news order by hits desc"
              rs.open sql,conn,1,1
              i=0
              do while (not rs.eof) and (i < 10)
              if i=1 then
                response.write("<img src='icon/1.gif'/>"&rs("title")&"<br>")
                elseif i=2 then
                response.write("<img src='icon/2.gif'/>"&rs("title")&"<br>")
                elseif i=3 then
                 response.write("<img src='icon/3.gif'/>"&rs("title")&"<br>")
                 elseif i=4 then
                 response.write("<img src='icon/4.gif'/>"&rs("title")&"<br>")
                 elseif i=5 then
                 response.write("<img src='icon/5.gif'/>"&rs("title")&"<br>")
                  elseif i=6 then
                 response.write("<img src='icon/6.gif'/>"&rs("title")&"<br>")
                   elseif i=7 then
                 response.write("<img src='icon/7.gif'/>"&rs("title")&"<br>")
                   elseif i=8 then
                 response.write("<img src='icon/8.gif'/>"&rs("title")&"<br>")
                 elseif i=9 then
                 response.write("<img src='icon/9.gif'/>"&rs("title")&"<br>")
                  elseif i=10 then
                 response.write("<img src='icon/10.gif'/>"&rs("title")&"<br>")
              i=i+1
              rs.movenext
              end if
              loop
              %>

写成这样了 好象是个死循环
#6
flynet2008-01-29 16:30
do while (not rs.eof) and (i < 10)
这个 不需要 再加 and (i<10)了吧? 已经规定了 是记录尾了 所以不会是死循环 i是根据 记录数进行自加过程 程序已经规定了top 10 了 不是死的
#7
flynet2008-01-29 16:31
i=0
不对 i=1
#8
sydpoechang2008-01-29 16:41
万一遇到10和11的hits数相同的话 就会被全部提取出来
#9
sydpoechang2008-01-29 16:44
改成i=1之后提示不允许操作~!
#10
madpbpl2008-01-30 02:11
do while (not rs.eof) and (i < 10)
              if i=1 then
                response.write("<img src='icon/1.gif'/>"&rs("title")&"<br>")
                elseif i=2 then
                response.write("<img src='icon/2.gif'/>"&rs("title")&"<br>")
                elseif i=3 then
                 response.write("<img src='icon/3.gif'/>"&rs("title")&"<br>")
                 elseif i=4 then
                 response.write("<img src='icon/4.gif'/>"&rs("title")&"<br>")
                 elseif i=5 then
                 response.write("<img src='icon/5.gif'/>"&rs("title")&"<br>")
                  elseif i=6 then
                 response.write("<img src='icon/6.gif'/>"&rs("title")&"<br>")
                   elseif i=7 then
                 response.write("<img src='icon/7.gif'/>"&rs("title")&"<br>")
                   elseif i=8 then
                 response.write("<img src='icon/8.gif'/>"&rs("title")&"<br>")
                 elseif i=9 then
                 response.write("<img src='icon/9.gif'/>"&rs("title")&"<br>")
                  elseif i=10 then
                 response.write("<img src='icon/10.gif'/>"&rs("title")&"<br>")
              end if             '-----这个移到前面来
              i=i+1
              rs.movenext
              loop
试试这样
#11
sydpoechang2008-01-30 15:29
<%
              Set rs=Server.CreateObject("ADODB.RecordSet")
              sql="select top 10 * from news where sort=19 order by hits desc"
              rs.open sql,conn,1,1
              i=1
              do while (not rs.eof) and (i < 10)
              response.write("<img src='icon/"&i&".gif'/>&nbsp;<a href='../hy/"&rs("moban")&"/ViewInfo.asp?idd="&rs("id")&"&id="&rs("UserID")&"'>"&mid(rs("title"),1,15)&"</a>&nbsp;<font color=ff0000>点击:"&rs("hits")&"次</font><br>")
              i=i+1
              rs.movenext
                          loop
              %>
写成这样 OK了
1