Unique Number

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
raggy99
Forum Newbie
Posts: 13
Joined: Mon Aug 14, 2006 6:52 am

Unique Number

Post 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.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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).
Post Reply