Jump to content

Random


bijan

Recommended Posts

What could be the best solution to create about 300,000 random numbers with 9 digits,without repitition and insert them in to a table ?I have used this method :for($j=1;$j<=300000;$j++){//number of records to insert $string=""; $snum='637419582016'; for($i=1;$i<=9;$i++){ $rnumb=rand(0,11); $string.=$snum[$rnumb]; }//------------checks the repitition by one query of the tableif ($totalRows_Recordset1>0) { $tempreg=$j-1;$regstatus="<B>ERROR- Repetitive Key Generation,</B> Generated ".$tempreg." key(s) out of 300000 keys";break;} It worlk well and takes every 1000 random number in one second to the table, but the repitiion occurs too soon in the 12000th to 20,000th number generation, Could there be a way to generate all numbers without the repition check ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...