sqlserver数据库很简单,一句代码搞定,比如: select * from news order by newid();
access数据库:
<%
set rs=server.createobject("adodb.recordset")
sql="SELECT newsid,title FROM news "
rs.open sql,conn,1,1
count=rs.RecordCount
Item=10
redim a(Item ,2),t(count)
for each j in t
j=0
next
Randomize timer
for j=1 to Item
k=int(rnd*count+1)
do while t(k)<>0
k=int(rnd*Item+1)
loop
t(k)=1
next
j=1:i=1
do while not rs.eof
if t(j)=1 then
a(i,1)=rs("n_id")
a(i,2)=rs("title")
i=i+1
end if
j=j+1
rs.movenext
loop
for i=1 to Item
%>
<a href="newsdetail.asp?newsid=<%=a(i,1)%>" target="_blank" class="bolded2"><%=a(i,2)%></a>
<%
next
rs.close
set rs=nothing
%>