Stoty Posted February 6, 2008 Share Posted February 6, 2008 Hi there, This might be a newbie questions, but was wondering how I can display the decimals on ALL numbers, not just ones with the decimal place being higher than '0' (eg 12.0)? I have a field in my database named "Total". Its set to FLOAT(3,1). In the table the values appear correctly, but when I display the info on a page they lose the decimal place unless the decimal is over "0". Example: In the DB On the page 12.0 12 17.0 17 26.0 26 etc. I want the values to display "12.0", "17.0", "26.0" on the page as well. How can I go about doing this? Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/89761-solved-showing-decimals/ Share on other sites More sharing options...
fenway Posted February 6, 2008 Share Posted February 6, 2008 Sound like a job for printf(). Quote Link to comment https://forums.phpfreaks.com/topic/89761-solved-showing-decimals/#findComment-460044 Share on other sites More sharing options...
rhodesa Posted February 6, 2008 Share Posted February 6, 2008 If they are numbers, I would suggest number_format() over printf Quote Link to comment https://forums.phpfreaks.com/topic/89761-solved-showing-decimals/#findComment-460055 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.