hejsan jag vill att den ska slumpa ut poster från payphone, nu tar den alltid fyra samma. Såhär fungerar slumptal:<code> Om MySQL stödjer IN kan du skriva:slumpa
<%
SQLvip = "SELECT * FROM payphone LIMIT 4"
Set vip = MinConn.execute(SQLvip)
Do until vip.eof
SQL = "Select * from userinfo WHERE ID='"& vip("ID") &"'"
Set rs = MinConn.execute(SQL)
%>
<td width="84" class="brod11b">
<div align="center"><%=rs("auth")%></div>
</td>
<%
vip.movenext
loop
vip.close
%>Sv: slumpa
<%
Randomize
Slump = Rnd * 50
%>
</code>Läs mer: http://www.ivarssons.nu/petter/asp/asp_lathund.htm#Slumptal
Man kanske kan lösa det med en sjysst SQL-sträng, men sånt är jag inte så hajj på.. :)Sv: slumpa
<code>
<%
Dim strIN
Dim strSQL
strSQL = "SELECT ID FROM payphone ORDER BY RAND() LIMIT 4"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, MinConn
strIN = rs.GetString( , , , ",")
rs.Close
strSQL = "SELECT * FROM userinfo WHERE ID IN (" & strIN & ")"
rs.Open strSQL
Do Until rs.eof
%>
<td width="84" class="brod11b">
<div align="center"><%=rs("auth")%></div>
</td>
<%
rs.movenext
loop
rs.close
%>
</code>
Annars kan du skriva:
<code>
<%
Dim strIN
Dim strSQL
strSQL = "SELECT ID FROM payphone ORDER BY RAND() LIMIT 4"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, MinConn
strIN = rs.GetString( , , , " OR ID = ")
rs.Close
strSQL = "SELECT * FROM userinfo WHERE ID = " & strIN
rs.Open strSQL
Do Until rs.eof
%>
<td width="84" class="brod11b">
<div align="center"><%=rs("auth")%></div>
</td>
<%
rs.movenext
loop
rs.close
%>
</code>