Jump to content


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 ?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...