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
https://forums.phpfreaks.com/topic/131055-area-code-value-incomplete/
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.

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.