NYCPHP Meetup

NYPHP.org

[nycphp-talk] generate random unique 8-digit number

Joey Derrico JoeyD473 at nyc.rr.com
Tue Mar 10 23:39:04 EDT 2009


One possibility would be to make a DB table with 2 columns. One where 
each row has a value from 00000000 through 99999999, and the other 
column marked as for used. When you need to generate the random number 
you can query the database for each # not currently used and select 
randomly from the values not in use and just update the DB to mark it as 
used so it won't come up again. You won't have repeating numbers then. 
However it will slow down your application because that is a lot of rows 
to go through.

Joey Derrico

chad qian wrote:
> Hi,
> I need to generate random 8-digit numbers continuously.And no 
> duplication among all those numbers.In other word,every single 8-digit 
> number must be unique.How to do php programming?
>  
> Thanks a lots!
>  
> chad
>
> ------------------------------------------------------------------------
> Express your personality in color! Preview and select themes for 
> Hotmail®. See how. 
> <http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme> 
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090310/b2820acb/attachment.html>


More information about the talk mailing list