View Full Version : Pulling a random member from my subscribed users.
manguish
02-28-2005, 08:34 PM
Right :
Scenario :
I wish to run a monthly draw for subscribed members. One will be pulled every month randomly.
Whats the easiest (and fairest) way to do this.
Is there an SQL command which will give me a random subscribing member userid?
Any input appreciated.
T3MEDIA
02-28-2005, 08:44 PM
I have been asking this for weeks.
manguish
02-28-2005, 08:46 PM
No joy i take?
pimpery
02-28-2005, 09:39 PM
No joy i take?
PHP Code to generate a random number.
rand({min},{max})
So rand(2, {users}) will return a random number that isnt 1.
For not two in a row
DO
$rand1 = rand(2, {users})
$rand2 = rand(2, {users})
UNTILL $rand1 !== $rand2
Something like that. Google search "php rand".
-{users} could be replaced with the variabe for total users in database.
ChrisBaktis
02-28-2005, 10:54 PM
This was made for me and it works GREAT!
Link (https://vborg.vbsupport.ru/showthread.php?t=73617&highlight=random+user)
Creed
02-28-2005, 11:43 PM
Nice, pulling a random user is very handy actually.
T3MEDIA
03-01-2005, 04:33 AM
should have that but pulling it to a template. then you can drop that anywhere on your site.
Michael Morris
03-01-2005, 09:19 AM
MySQL has a rand function as well, though I don't know it off hand. I'm sure it's in the docs somewhere.
manguish
03-01-2005, 11:34 AM
Cheers people - worked a treat ;)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.