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. Link to comment https://forums.phpfreaks.com/topic/79927-solved-zip-code/ 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 Link to comment https://forums.phpfreaks.com/topic/79927-solved-zip-code/#findComment-404852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.