1,105,242 Community Members

Insert decimal value in price field

Member Avatar
Fiorentino01^
Junior Poster in Training
76 posts since Oct 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi I am doing a Tizag tutorial.I have created this table products with phpMyAdm in and started to populate the field.When it comes to price if I insert 13.99 the amount is rounded up to 14.I have tried everything changing to decimal, float, double but nothing seems to work,it keeps rounding up the amount.Can somebody figure out what is the problem? This is important as I'll have to insert decimal values a lot.Thank you.

Member Avatar
TonyG_cyprus
Posting Whiz
329 posts since Dec 2009
Reputation Points: 36 [?]
Q&As Helped to Solve: 47 [?]
Skill Endorsements: 2 [?]
 
0
 

Can you post the code? We can then see any maybe problems.

Member Avatar
Fiorentino01^
Junior Poster in Training
76 posts since Oct 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Tizag mysql tutorial-groupby
Table Products-DB test
All the price column amounts get rounded up to the next dollat example id 123451 Park's Great Hits Music Price 19.99 my select query shows 20.00 and same for all other columns 3.99 to 4.00 and so on.
The table structure is id int(10)name varchar(20)type varchar(30)price-I've tried everyone decimal,float,double the result is still the same the amount is rounded up.Cannot figure it out.Thanks

Member Avatar
TonyG_cyprus
Posting Whiz
329 posts since Dec 2009
Reputation Points: 36 [?]
Q&As Helped to Solve: 47 [?]
Skill Endorsements: 2 [?]
 
0
 

try-
price type DECIMAL length 4,2
the ',2' being the number of decimal places.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: