*WHY* not use auto_increment?
Would the builtin http://php.net/uniqid function not work better?
*NEVER* seed the random number generator more than once per script. Call
srand() once, and only once.
The return() statement will return the MySQL resource ID, which is probably
not useful, but all the other variables will be forgotten so I think
whatever pointer and loop position 0 you mean will be reset-- assuming all
this is in a function.
You are limiting yourself to 99999 - 10000 records, which is pretty small.
Basically, you almost for sure are making your life difficult and should
just use auto_increment.
----- Original Message -----
From: AJDIN BRANDIC <[EMAIL PROTECTED]>
Newsgroups: php.general
Sent: Tuesday, January 09, 2001 11:14 AM
Subject: [PHP] unique id
> Hi again,
>
> I am generating a randum number but before inserting it into a table I
> want to make sure that onother number with the same value doesn't exist
> in the table. Here is what I have:
>
> srand((double)microtime()*1000000);
> $ran_num = rand(10000, 99999);
>
> $query01 = "SELECT thisnum FROM mytable";
> $results = mysql_query($query01) or die("Failed on select
> mytable!");
>
> while ($result = mysql_fetch_array($results)) {
> $thisnum=$result['thisnum'];
> if($ran_num==$thisnum) {
> srand((double)microtime()*1000000);
> $ran_num = rand(10000, 99999);
> reset($results)
> // will this reset the pointer and will the
> while loop start from position 0??? If not how do I force the check to
> start from position 0?
> }
> }
>
> I donot want to use autoincrement???
>
> Thanks
>
> Ajdin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]