Hello,
I am trying to implement the best way to check a Member ID field and make sure the new randomly generated Member ID is not duplicated in the database.
I am using mysql 4.2. I understand how to check the database for a match, but I am not sure if I am using the best method to regenerate a new Member ID if a match is found..
I want to know the best way to regenerate a new member ID if a match is found and recheck the database again..
This is the script I've been using:
while($row = mysql_fetch_array($result))
{
$ckmemid =($row['MemID']);
if ($tmemid==$ckmemid){
while ($tmemid==$ckmemid){
$tmemid=rand(0000,9999);
}
}
It randomizes a 4 digit code. But it appears that after the new code is randomized after finding a match, it will not fully recheck the entire database again with the new randomized ID.
If a match is found in the database, should I just reload the page to have the query start from the top of the database again?
Thanks for any help on this issue..