Reputation: 103
I have a dropdown box here with list of salaries..when i tired to save it to the database it only shows the first 2 digit like 11 or 12 or 15 or 16.
Salary:<select name="salary">
<option></option>
<option value="11,181"> 11,181 </option>
<option value="12,975"> 12,975 </option>
<option value="15,594"> 15,594 </option>
<option value="16,051"> 16,051 </option>
</select>
how to save it?? my field datatype for salary is float is it correct?
Upvotes: 0
Views: 996
Reputation: 219804
Without seeing your code the most likely cause of your problem is you have an integer data type for that column in your database. That means you will need to remove the comma from the value before you save it or MySQL will truncate the value up to the comma.
$salary = str_replace(',', '', $_POST['salary']);
An alternative way to handle it is to remove the comma when populating the select drop down:
<option value="11181"> 11,181 </option>
<option value="12975"> 12,975 </option>
<option value="15594"> 15,594 </option>
<option value="16051"> 16,051 </option>
Upvotes: 2