I have a lottery system on my site where users can pick a 6 digit number
the DB tables has a row "ticket"
Here is my DB table structure
uid
ticket
cash
I need a way where a php script will pick 6 random numbers for them and make sure this number picked is not already a row in the DB "ticket"
Currently they can make there 6 digit number up by picking 6 different numbers but I want a faster way for them to pick a random number
so the script will pick a random 6 digit number but make sure it has not already been picked by a user any help appreciated I'm lost how to make sure its not picked
The only way I know how to do it is to
- create my random number
- check if it exist in DB, if it exist create another random number and try this cycle over and over again until it gets one right that isnt already in the DB
Is there a more efficent way of doing this instead of checking against the DB every single time until I get an available spot?