Hi people,

My issue is more of a MySQL issue than php.
I am trying to store a 3digit integer value with a leading Zeros in front such as 001

i have a company table , which auto increments the id as 001, 002, 003...and so on...
In the company table i also have a country radio box..
Which has two country names,
eg: India, Australia..

So when creating the company..
The user types in the data and select a country eg: India,
The Id should be I001,
The next record if he chooses Australia,,, then it will be
A002 ... A003, I004..and so on...till A999(as the last record).

Can anyone help me how to implement this?..

Ur help is much appreciated...
Thanks in advance..

Recommended Answers

All 4 Replies

AUTO_INCREMENT can only be numeric. For leading zeros you can set the field to ZEROFILL.You should concatenate character while displaying the data.

AUTO_INCREMENT can only be numeric. For leading zeros you can set the field to ZEROFILL.You should concatenate character while displaying the data.

Hi mwasif,

Thanks, i used as numeric field and used Zerofill..
It helped me a lot..
Thanks again

You are welcome tryphy.

I just had this exact problem with tel numbers having a leading zero - 011 123 4567 would be stored as 11 123 4567.

These numbers are entered from a php online form.

I checked the DB field for tel_number which is VARCHAR with length 12 and saw that it was missing the collation parameter - this was blank.

Changing that to " latin1_swedish_ci" seems to have fixed the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.