karatekid36 Posted December 3, 2007 Share Posted December 3, 2007 Hey Everyone, What is the best way to store zip codes in a db? I can not get the zip code to display properly if it starts with a 0 meaning the 0xxxx wont display, only the xxxx. Thank you for the help. Quote Link to comment Share on other sites More sharing options...
toplay Posted December 3, 2007 Share Posted December 3, 2007 You're getting that because your column I assume is numeric. Use LPAD() MySQL function to retrieve always 5 digits. Otherwise, change the column to a character type (varchar). http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_lpad PHP function: http://us2.php.net/manual/en/function.str-pad.php 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.