只显示数据库 前8条 40分题目

cp713 2008-12-02 09:24:55
<%
Set rs= Server.CreateObject("ADODB.recordset")
rs.open "Select top 8 * from 产品 where 类型=1 order by 点击 desc",lj,1,1
i=0
Do until rs.eof
i=i+1
%>
<tr><a href="MoNi-open.asp?id=<%Response.Write(rs("id"))%>">
<td height="25" bordercolor="#FFFFFF" bgcolor="#E2E2E2" class="ZT-hei" onmouseover="this.style.color='#FFFFFF';this.style.backgroundColor='#999999';" onmouseout="this.style.color='#000000';this.style.backgroundColor='#E2E2E2';"> <img src="images/top<%=i%>.gif">  <%Response.Write(rs("名称"))%></td>
</a></tr>
<%
Rs.movenext
Loop
rs.close
set rs=nothing
%>



根据点击数 为什么不是前八条
而是点击数前把 比如 第八 和第九和第十 点击数相同
就一起显示出来了 就一共显示十条了
这么做才能只显示前八条 别告诉 把点击 换 id
...全文
67 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jbj001 2008-12-03
  • 打赏
  • 举报
回复
order by 的时候把标识字段id,也加上就行


cp713 2008-12-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 yxxue 的回复:]
是楼主描述的有问题还是我一直是错的?TOP 8 会显示出10条数据吗????
[/Quote]

这就不懂了把 呵呵
zjzb0409 2008-12-02
  • 打赏
  • 举报
回复
rs.open "Select top 8 * from 产品 where 类型=1 order by 点击,id desc",lj,1,1

你在 点击后边再加个id 就是,id 因为 id号是没有重复的 这样 根据 点击,id 排序后 就是8条了 我以前碰到过和你一样的问题
yxxue 2008-12-02
  • 打赏
  • 举报
回复
是楼主描述的有问题还是我一直是错的?TOP 8 会显示出10条数据吗????
Atai-Lu 2008-12-02
  • 打赏
  • 举报
回复
有没有唯一标识的列?多字段排序就好了
ddreamc 2008-12-02
  • 打赏
  • 举报
回复
Select top 8 * from 产品 where 类型=1 order by 点击 desc,id

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧