chambers9661 Posted June 15, 2020 Share Posted June 15, 2020 Hi there, I have a database with table column called EXPAMOUNT if EXPAMOUNT value was £5.50 it only displays £5.5. when i echo it. How do i get it to display 2 decimal places. So £5.50 My code at moment echo “Total Expenses   £” . $row[‘SUM(EXPAMOUNT)’]. “ Quote Link to comment https://forums.phpfreaks.com/topic/310938-decimal-placing/ Share on other sites More sharing options...
Barand Posted June 15, 2020 Share Posted June 15, 2020 Take your pick SQL SELECT FORMAT(SUM(EXPAMOUNT), 2) as exptotal PHP $x = 5.5; echo sprintf("%0.2f", $x) . '<br>'; //--> 5.50 echo number_format($x, 2); //--> 5.50 Quote Link to comment https://forums.phpfreaks.com/topic/310938-decimal-placing/#findComment-1578899 Share on other sites More sharing options...
chambers9661 Posted June 15, 2020 Author Share Posted June 15, 2020 Thanks i will try it. Quote Link to comment https://forums.phpfreaks.com/topic/310938-decimal-placing/#findComment-1578903 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.