Requette SQL RANDOM

fabiin Messages postés 329 Date d'inscription mercredi 4 avril 2001 Statut Membre Dernière intervention 8 décembre 2009 - 9 janv. 2002 à 20:57
cs_axelred Messages postés 1 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 5 février 2002 - 5 févr. 2002 à 00:25
Salut !
Quel qu'un pourrait me donner un exemple ki marche utilisant la requette SQL
"SELECT RANDOM FROM table"
car cet exemple ne fonctionne pas :)

Merci par avance

@+
Fabs 8-)

1 réponse

cs_axelred Messages postés 1 Date d'inscription mardi 5 février 2002 Statut Membre Dernière intervention 5 février 2002
5 févr. 2002 à 00:25
salut,
essaye ce code, il marche très bien. bon program...
axel
<%
Dim edito__MMColParam
edito__MMColParam = "1"
if (Request.QueryString("origine") <> "") then edito__MMColParam = Request.QueryString("origine")
%>
<%
if refquestion=0 then
'---------------sélection des messages correspondant au thème---------
Set CONN = Server.CreateObject("ADODB.Connection")
CONN.Open "DSN"
Set rs = Server.CreateObject("ADODB.Recordset")%>
<%
rs.open "select* from nom_de_la_table", CONN
if rs.eof=true then
%>
pas de message(s) correspondant(s)
<%else%>
<%
rs.movefirst
compteur=0
'-------------------------cette boucle comptabilise le nombre de messages pour le thème choisi-------------------
do while not rs.eof
compteur=compteur+1
rs.movenext
loop
%>
<%n=compteur%>
<%'-----------------------génération d'un nombre aléatoire sur le nombre de messages correspondants--------------
Randomize Timer
aleatoire=Int(Rnd * n)+1
%>
<%rang=0%>
<%rs.movefirst
'-------------------------cette boucle cherche le message correspondant au nombre tiré au hasard-----------------
do while not rs.eof%>
<%rang=rang+1%>
<%if rang=aleatoire then%>

<table width="100%" border="0" cellspacing="0">

----,

<%=rs(\"champ1\")%>

</td>

<%end if%>
<%rs.movenext
loop%>
<%end if%>
<%
rs.close
Set rs=nothing
CONN.close
Set conn=nothing
%>
<%end if%>


</td>
</tr>

</table>
0
Rejoignez-nous