how to generate customized ID automatically using php/mysql?

hi experts!,

simply my problem is that i want to generate some id (ProjectID) automatically (user haven't to worry about entering this field), but my issue is that this id must be intelligent in other words it is not just auto incremented field. it consists of two parts (text and serial number of specific number of digits). to make it much clear lets consider this scenario:
i have a text field in my form that is filled by user, this is the field which i use to generate the ProjectID
if for example the user entered in this field the value ("test") and this was the first entery in my list of prjects then the ProjectID must be ("test00000001").
furthermore the number of digits (of the numeric part) is exactly 8 digits. i know that for the first part of the generated id it is straightforward just get user value and put it in. the problem is in the rest .
examples of generated ids:

ProjectID:
*************
iddr00000002                     -> corresponds to project number 2   -> user entered  (iddr)
amcu00000100                   -> corresponds to project number 100        -> user entered (amcu)
someText00020003            -> corresponds to project number 20003             -> user entered (someText)

i think it is clear now. one thing is that the number part must be 8 digits length, left padded with zeros as above examples exaclty.

i am using php5 with mysql 5 also and apache 1.3 (just FYI).
thanks to all participants in advance.
for more info please ask.
LVL 3
AymanAdamAsked:
Who is Participating?
 
ahoffmannConnect With a Mentor Commented:
$id=42;
$id=sprintf("%08d",$id);
$id++;
$id=sprintf("%s%08d",$usertext,$id);
0
 
ahoffmannCommented:
$id=42;
$id=sprintf("%08d",$id);
0
 
ahoffmannCommented:
$id=sprintf("%s%08d",$usertext,$id);
0
 
AymanAdamAuthor Commented:
ahoffmann, now how to make the numeric value auto incremented?
i mean i have to make this 8 digits auto incremented what can i do in this case?
0
 
AymanAdamAuthor Commented:
thanks ahoffmann,

there are some minors remaining but i can deal with them.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.