How we are going to choose the winner:
As you can see, this returns 10 rows. the (round(rand()*10) + 1) returns a number between 1 and 10 (there's probably an easier way to do this, but that's how I did it
). This number between 1-10 will be the row that I look at in the 10 results that it returns. I'll look at the rownum from the first row returned to determine which row to look at.
After selecting a winner, we'll do some "auditing" to make sure nothing looks fishy, and will then announce the winner. The result is final unless we find out the user somehow cheated or is in violation of the rules.
As you can see, if you don't have more than 1 post, your chance of winning is 0. It's a better chance than I have of winning... but not by much.
- Code:
SELECT u.user_id, u.username,
p.post_id, p.poster_ip, u.user_posts, (round(rand()*10) + 1) as rownum
FROM phpbb_posts p, phpbb_users u
WHERE p.topic_id = 14010
AND u.user_id <> - 1
AND p.poster_id = u.user_id
AND u.user_posts > 1
ORDER BY rand() + rand()
LIMIT 10
As you can see, this returns 10 rows. the (round(rand()*10) + 1) returns a number between 1 and 10 (there's probably an easier way to do this, but that's how I did it
After selecting a winner, we'll do some "auditing" to make sure nothing looks fishy, and will then announce the winner. The result is final unless we find out the user somehow cheated or is in violation of the rules.
As you can see, if you don't have more than 1 post, your chance of winning is 0. It's a better chance than I have of winning... but not by much.