|
-
Jun 11th, 2001, 02:08 PM
#1
Thread Starter
Member
Need help Randomizing ?? Please take a look
I am trying to create a sql select statement that pulls out records in a random order and then I would like to display them in that random order.
Any suggestion on the select statement and the actuall code to display would be vastly apreciated.
Kind Regards,
Hakan
-
Jun 12th, 2001, 01:48 AM
#2
Lively Member
What I would do is..
Get your recordset. Get the count of the recordset.
Use can use rnd function in ASP.
not actuall code but give you an idea
do while not rs.eof
x = rnd(1 * 10) + 1
if x < 5 then
response.write rs("Field")
end if
rs.movenext
loop
just check for the RND function, It is in the MSDN.
-
Jun 12th, 2001, 07:21 AM
#3
Thread Starter
Member
Thank you for your reply, I haven't tried it yet but one quick question what is the "if x < 5" for.
Thank You
Hakan
-
Jun 13th, 2001, 02:49 AM
#4
Lively Member
the if x < 5 is for every random number smaller than 5.
but a more effective way is:
Declaring a ADODB.Recordset
Use the RND function to get a random number
Use the Rs.Move to go to the Random number.
Just use a check for the number of records returned.
If will post a example..
-
Jun 13th, 2001, 02:54 AM
#5
Lively Member
http://www.4guysfromrolla.com/webtech/081100-1.shtml
Will show you how to use a stored proc to generate random record.
-
Jun 13th, 2001, 02:58 AM
#6
Lively Member
this is the way I describe in doing it... but more in detail. (The way you wanted it)
http://www.4guysfromrolla.com/webtech/072799-1.shtml
Sorry for not posting the code, but I'm busy. It easier to point you to a correct link
-
Jun 13th, 2001, 09:15 AM
#7
Thread Starter
Member
I have gotten past that, thank you for your post. If you want to see my new problem go here
http://161.58.186.97/showthread.php?s=&threadid=82615
Thanks for your help bud,
Kind Regards,
Hakan Azaklioglu
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|