pioneerx01 Posted January 9, 2011 Share Posted January 9, 2011 How can I make sure that when I submit an new form and new ID (record) is created it is always 4-Digits. record 14 = 0014, record 225 = 0225. Thanks Link to comment https://forums.phpfreaks.com/topic/223839-how-to-code-4-digit-id-code-into-mysql-via-php/ Share on other sites More sharing options...
smerny Posted January 9, 2011 Share Posted January 9, 2011 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 Link to comment https://forums.phpfreaks.com/topic/223839-how-to-code-4-digit-id-code-into-mysql-via-php/#findComment-1156938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.