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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.