我们有15个产品,每天在主页要它随机的显示三条?你说这样怎么编? 急急!!

liyefei 2004-04-07 09:52:59
我们有15个产品,每天在主页要它随机的显示三条?你说这样怎么编?
...全文
29 点赞 收藏 13
写回复
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianxuehua 2004-04-07
最简单的:
sql server
select top 3 * from tabel order by newID()
access
select top 3 * from tabel order by rnd(id)
回复
randomize
RNumber=int(rnd*15)
RNumber2=int(rnd*15)
RNumber3=int(rnd*15)
SQL = "SELECT * FROM Customers WHERE ID in (" & RNumber & ", " & RNumber2 & " ," & RNumber3&")"
回复
lonaerd 2004-04-07
dim dst1(2)

dst1(0)=cint(rnd*15)
dst1(1)=cint(rnd*15)
dst1(2)=cint(rnd*15)

然后判断这三个数是否相等,如果相等再决定加1或减1,最终就是得到三个0-14并且互不相等的数。
得到三个数字后接下来我就不多说了



回复
set top 3 * from tabel order by newID()
这个就是啊
回复
mustapha 2004-04-07
order by newID() 就是随机显示,不信你试试
回复
aseadi 2004-04-07
<%
randomize
for i=1 to 3
j=int((6-1+1)*rnd+1)
sql="select * from body where bodyid="&j
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
response.Write(rs("body"))&"<br>"
rs.close
next
set conn=nothing
%>
回复
bybee 2004-04-07
sql server
select top 3 * from tabel order by newID()
access
select top 3 * from tabel order by rnd(id)
回复
aseadi 2004-04-07
<%radonmize
i=(15-1+1)*rnd+1
sql="select top 3 * from table where id="&i
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof
response.write rs("news")
rs.movenext
loop%>记得关闭数据rs和数据库哦!!呵呵!!
回复
Newrocky 2004-04-07
随机抽取3条出来以后,再显示
'建立DCNDB连接
RS.OPEN "SELECT top 3 * from tabel order by newID()",DCNDB,1,1
DO WHILE NOT RS.EOF
response.write rs(0)
rs.movenext
loop
回复
aseadi 2004-04-07
随机id
回复
Jaron 2004-04-07
select top 3 * from [tabel] order by newid() 从表中随机抽取三条记录.
回复
liyefei 2004-04-07
老大我说的是随机显示三条记录啊,有高招么?
回复
mustapha 2004-04-07
set top 3 * from tabel order by newID()
回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告