Jump to content

<select> area code value incomplete


vinpkl

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.