View Full Version : vBulletin 4 Request - Looking for a Drawing/Raffle Mod
MrFurious
01-27-2017, 08:57 PM
I'm looking for a vb4 mod to pick random users from my database for product give-aways. I need to be able to specify what usergroup(s) are eligible for the drawing, and only select from those who have been active on the forum in a given amount of time (1 month, 6 months, 1 year, etc.)
I'm a business guy, not a programmer - so a simple plugin or mod would be best. I am savvy enough to run a SQL query via Maintenance if if I have a query I can just C&P.
Never imagined it would be this much of a headache to give something away. lol
scottkoz20
01-28-2017, 02:23 AM
this might be useful for you
https://vborg.vbsupport.ru/showthread.php?t=316944&highlight=raffle
MrFurious
01-28-2017, 02:43 AM
I'm not looking for something that extensive or elaborate, I just want a simple "click the button and get a name" or "paste a query and get a result" for the oddball drawing I do now and then to give something away.
MarkFL
01-28-2017, 03:35 AM
Suppose you wanted to pick a user at random from usergroups 6 and 9, then you could use this query:
SELECT user.username FROM user AS user WHERE usergroupid IN (6,9) OR FIND_IN_SET(6,membergroupids) OR FIND_IN_SET(9,membergroupids) ORDER BY RAND() LIMIT 1
The limit of 1 will be ignored, so either just take the first name shown, or set "Results to Show Per Page" at 1. :)
MrFurious
01-28-2017, 06:57 AM
If I use this query:
SELECT user.username FROM user AS user WHERE usergroupid IN (16,103,104,105,106) OR FIND_IN_SET(16,membergroupids) OR FIND_IN_SET(103,membergroupids) FIND_IN_SET(104,membergroupids) OR FIND_IN_SET(105,membergroupids) OR FIND_IN_SET(106,membergroupids) OR ORDER BY RAND() LIMIT 1
I get this error:
An error occurred while attempting to execute your query. The following information was returned.
error number: 1064
error desc: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FIND_IN_SET(104,membergroupids) OR FIND_IN_SET(105,membergroupids) OR FIND_IN_SE' at line 1
Using this shortened version:
SELECT user.username FROM user AS user WHERE usergroupid IN (16,103,104,105,106) ORDER BY RAND() LIMIT 1
I get the following error:
An error occurred while attempting to execute your query. The following information was returned.
error number: 1146
error desc: Table 'savagesh_vBull_CMS_Prod.user' doesn't exist
Like I said, I'm not a programmer. :confused: MySQL version is 5.5.52-cll if that matters any.
MarkFL
01-28-2017, 07:14 AM
In the first query, you have an "OR" that's misplaced. In the second, I am guessing you need to specify a table prefix before "user AS user".
TheAdminMarket
01-28-2017, 10:12 AM
$this_user = $db->query_first("SELECT username FROM ".TABLE_PREFIX."user WHERE usergroupid IN (16,103,104,105,106) OR FIND_IN_SET(16,membergroupids) OR FIND_IN_SET(103,membergroupids) OR FIND_IN_SET(104,membergroupids) OR FIND_IN_SET(105,membergroupids) OR FIND_IN_SET(106,membergroupids) ORDER BY RAND()");
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.