gerkintrigg Posted August 4, 2006 Share Posted August 4, 2006 Hi. this is probably a very simple question, with a very simple answer, but it's baffling me...Does anyone here know how to echo a MySQL float variable as two decimal places? Currently I'm using it to store prices in a database and whenever a cost if like £1.50p it only displays £1.5 which simply looks wrong.Can anyone help please?Thanks. Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 4, 2006 Share Posted August 4, 2006 I know the round function worksround(5.2545, 2) would be 5.25round(1.5,2) should in theory be 1.50 Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 4, 2006 Share Posted August 4, 2006 Also check out the number format and the money format functionshttp://es2.php.net/manual/en/function.number-format.phphttp://es2.php.net/manual/en/function.money-format.php Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted August 4, 2006 Author Share Posted August 4, 2006 Eventually i used:printf("%.2f", $total);Thanks everyone. Quote Link to comment 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.