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
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.
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):