douyanlu7380 2014-03-31 14:03
浏览 18

从成千上万的用户中选择可能有数百张票的抽奖券

I am creating a raffle and at the moment have a database with username and the amount of tickets assigned to them. The only fair way I can think of selecting a winner fairly i.e. the more tickets you have, the higher the odds of winning are; is by creating a separate table with users names listed multiplied by the amount of tickets they have and randomly selecting one. This would create an enormous database. What is the best way to go about selecting the winner? Preferably via PHP.

EDIT* Users gain ticket i.e. +1 to 'tickets'. The tickets do not actually have anything assigned to them to make them different from the rest.

Username Tickets Tinman 55

Thank you in advance.

  • 写回答

2条回答 默认 最新

  • dongyou6768 2014-03-31 14:20
    关注

    You would just have a table of users and raffle ticket numbers...

    John  108
    John  109
    John  110
    Paul  111
    

    John has 3 times as many chances of winning as Paul.

    评论

报告相同问题?