Forum Moderators: coopster

Message Too Old, No Replies

ID help

Help with custom IDs for php/mysql

         

cremesoda201

3:24 pm on Apr 19, 2005 (gmt 0)

10+ Year Member



I'm making a simple php/mysql registration form that submits to a database and e-mails the owner with the information. Easy. But I'm not sure how to implement the following:

The client wants something in front of the ID. Such as..if someone registers their client ID would be:

MDWG14W005
MDWG14W006
etc.

So there would be a part that never changes, and the end characters unique. How would I go about implementing this? Would I do it within the php page or on the mysql side of things.

Thanks.

timster

5:07 pm on Apr 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest retaining the numerical primary key.

You can accomodate the request for pretty product numbers a couple ways. If you're using a new version of MySQL you can use a trigger [dev.mysql.com] to create the pretty product numbers based on the numerical key.

It could be seen as a waste having a separate field for the pretty id, but it's probably easier that way than always using PHP to prepend the alphanumeric before the "real" id. More flexible, too, for when the client whats to change the way the product numbers work.

[edited by: jatar_k at 6:20 pm (utc) on April 19, 2005]
[edit reason] added proper link [/edit]