1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Lottery game code

Discussion in 'Programming' started by Osman 46433, Jan 22, 2016.

  1. #1
    Hi I'm trying to create a game where a user types 6 numbers from 1-59 and generates random raffle like blue 4243 8654 and stores them into a database and select a Radom raffle winner
     
    Osman 46433, Jan 22, 2016 IP
  2. ArhamSoft

    ArhamSoft Member

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    Hi,
    I am sharing code with you 4243 8654.please check
     
    ArhamSoft, Jan 25, 2016 IP
  3. Osman 46433

    Osman 46433 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    Im trying to generate raffles numbers like Aqua 2332 9643
     
    Osman 46433, Jan 25, 2016 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,500
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #4
    What programming language are you going to use?
    Is your problem just creating the random numbers?
     
    sarahk, Jan 26, 2016 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    If you're gonna generate random raffle-numbers (out of a somewhat limited set, I presume?), why not just have a button users can click on for the random numbers to be generated? Why do you need the user to enter digits (fewer digits than what's actually used for the ticket numbers, it seems). And if you want it to use a color, or word, in front of the numbers, you'll need an array, or something, of words it's allowed to pick (a dictionary of sorts).

    Creating the random numbers isn't hard, however, if you only create numbers, without setting any type of limiter on the generation, you have quite a few possible combinations of numbers - you might have quite a few raffles without any winners if you do it that way. Depending on how many users you plan on having, 4 digits gives you 9999 tickets. 8 digits gives you 99999999 (that is 99 million) tickets. That is... a lot. Add to that random words in front, if you say have 10 different colors, that's 10 * 99 million. And so on and so forth.

    The important thing to ask is: why am I doing this? Is this something where you want to have a winner every time the raffle is drawn? How are you gonna determine which tickets wins? If you just want to generate random numbers, and select 1 - 3 of those for winners when the draw is done, then no problem - only thing you need to be sure of then is that the numbers are unique.
     
    PoPSiCLe, Jan 26, 2016 IP
    ThePHPMaster likes this.
  6. dangerousYY

    dangerousYY Member

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    If you want to use PHP it would be much simple than you can think.

    Best of luck!

    <?php
    
    // choose the range of numbers
    $numbers = range(1,59);
    // shuffle your desired range of numbers
    shuffle( $numbers );
    // that's it, you have 6 random numbers from your desired range
    $lucky_numbers = array_slice( $numbers, 0, 6 );
    
    // now you have your lucky numbers, let's test them
    
    echo 'The lucky numbers are: ' . implode( ', ', $lucky_numbers );
    Code (markup):
     
    dangerousYY, Feb 2, 2016 IP