sid0972 Posted February 10, 2013 Share Posted February 10, 2013 i already have the particular column as float, and input is of the form 9999.999 i dont think if number_format's going to be of much help here. What should i use?? Quote Link to comment https://forums.phpfreaks.com/topic/274300-hwo-to-i-store-decimal-value-in-database/ Share on other sites More sharing options...
sid0972 Posted February 10, 2013 Author Share Posted February 10, 2013 silly me varchar() works fine. thanks for looking though Quote Link to comment https://forums.phpfreaks.com/topic/274300-hwo-to-i-store-decimal-value-in-database/#findComment-1411559 Share on other sites More sharing options...
Barand Posted February 10, 2013 Share Posted February 10, 2013 DECIMAL(8,3) Quote Link to comment https://forums.phpfreaks.com/topic/274300-hwo-to-i-store-decimal-value-in-database/#findComment-1411563 Share on other sites More sharing options...
sid0972 Posted February 10, 2013 Author Share Posted February 10, 2013 can i have an example please? Quote Link to comment https://forums.phpfreaks.com/topic/274300-hwo-to-i-store-decimal-value-in-database/#findComment-1411583 Share on other sites More sharing options...
kicken Posted February 10, 2013 Share Posted February 10, 2013 Just define the column as a DECIMAL(8,3) type and then insert the number. CREATE TABLE blah ( num DECIMAL(8,3) ); INSERT INTO blah (num) VALUES (9999.999) Quote Link to comment https://forums.phpfreaks.com/topic/274300-hwo-to-i-store-decimal-value-in-database/#findComment-1411584 Share on other sites More sharing options...
Barand Posted February 10, 2013 Share Posted February 10, 2013 can i have an example please? I just did DECIMAL(8,3) OK Here's the served-up-on-a-plate answer Instead of VARCHAR(xx) use DECIMAL(8,3) Quote Link to comment https://forums.phpfreaks.com/topic/274300-hwo-to-i-store-decimal-value-in-database/#findComment-1411586 Share on other sites More sharing options...
sid0972 Posted February 11, 2013 Author Share Posted February 11, 2013 I just did OK Here's the served-up-on-a-plate answer Instead of VARCHAR(xx) use DECIMAL(8,3) i thought it was a function of php but kicken cleared it well and good. Quote Link to comment https://forums.phpfreaks.com/topic/274300-hwo-to-i-store-decimal-value-in-database/#findComment-1411731 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.