vinpkl Posted November 2, 2008 Share Posted November 2, 2008 hi all i have a <select> with options for area code in my form. In the database i have its datatype as int(5). when i select any option and submit form then i get the area code result as "3" or "4" or "5" in my database. How can i get the area code result as "03" or "04" or "05" here is the <select> code <select name="customer_contact_code" id="customer_contact_code"> <option value=""> </option> <option value="03">03</option> <option value="04">04</option> <option value="06">06</option> <option value="07">07</option> <option value="09">09</option> </select> vineet Link to comment https://forums.phpfreaks.com/topic/131055-area-code-value-incomplete/ Share on other sites More sharing options...
Jeremysr Posted November 2, 2008 Share Posted November 2, 2008 The type int(5) only stores numbers. '03' is a string, not a number. It's a visual representation of the number three. To solve this, you can either change the type in the database to a varchar, or still store it as a number and convert it to a string with a leading zero after retrieving it from the database. Link to comment https://forums.phpfreaks.com/topic/131055-area-code-value-incomplete/#findComment-680422 Share on other sites More sharing options...
vinpkl Posted November 2, 2008 Author Share Posted November 2, 2008 The type int(5) only stores numbers. '03' is a string, not a number. It's a visual representation of the number three. To solve this, you can either change the type in the database to a varchar, or still store it as a number and convert it to a string with a leading zero after retrieving it from the database. hi jeremysr thanks for the reply. now i understood what to change. vineet Link to comment https://forums.phpfreaks.com/topic/131055-area-code-value-incomplete/#findComment-680427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.