vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Pulling a random member from my subscribed users. (https://vborg.vbsupport.ru/showthread.php?t=77219)

manguish 02-28-2005 08:34 PM

Pulling a random member from my subscribed users.
 
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

Quote:

Originally Posted by manguish
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

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 ;)


All times are GMT. The time now is 08:43 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02425 seconds
  • Memory Usage 1,717KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete