Jump to content

How to code 4-Digit ID code into MySQL via PHP


pioneerx01

Recommended Posts

when you create (or alter) the table, use attributes "UNSIGNED ZEROFILL" and the MySQL will do it for you

 

if you want to zerofill in php... try the str_pad

 

str_pad($number, $digits, "0", STR_PAD_LEFT);

 

where $number is the number and $digits is how many digits you want it to fill to... but this if you put this in a numeric field in MySQL it would revert to a number and lose the zerofill anyway

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.