Rikuto Teshika
Rikuto Teshika

Reputation: 23

how can i input a float value with 0 as it last digit into database?

so, i have a problem that doesn't really sure how to fix it, lets say i have :

<input type="number" id="input" name="input" class="form-control" placeholder="insert here" step=".01" required></br>

and i have a database to it witch is float. but every time i input with x.x0 the 0 in the end is always disappear.

any thought? thank you

Upvotes: 2

Views: 681

Answers (2)

brian marcius
brian marcius

Reputation: 110

You can put 2 after the length of your field like FLOAT(15,2) for 2 digit after .

ALTER TABLE tablename MODIFY columnname FLOAT(15,2) ;

Upvotes: 0

Kamran
Kamran

Reputation: 531

Changing MySQL column type from float into Decimal keeps trailing zeros. Here I create a test and example.

create table trailing_zeros (input_number decimal(15,2))

Upvotes: 2

Related Questions