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 Quote Link to comment 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. Quote Link to comment 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 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.