Page 1 of 1

Unique Number

Posted: Mon Aug 14, 2006 7:02 am
by raggy99
What i want to do is create a Automatic Unique 6 didget number. For a user I.D when i create a New Member for my website.
So the code will:-
Have to make sure it is 6 didgets
Be Automatic
Search other ID Numbers in the UserId in the datebase so it is unique.

I'm new to all this php stuff so i'm a BIG Noooooob.
Hope you can help.

Posted: Mon Aug 14, 2006 8:03 am
by onion2k
Just create a database table for your users with a field set to AUTO_INCREMENT. Probably a good idea to set it as the primary key too.

When you display the number, use a function to convert it to 6 digits (sprintf() or str_pad() or whatever).