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
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show_participation.php

Reply via email to