Jump to content

[SOLVED] Decimal Display


phpretard

Recommended Posts

How I get ".00" to show if there is nothing after the decimal in the Database.

 

For example if I insert 2.00 [decimal (10,2)] in the database the php will only display the ".00" if there is a value after the decimal.

 

The code works fine it's the .00 that's got me.

 

function getBalance(){

connect();

$balanceQ=mysql_query("select cart.eventID, cart.userID, 
competitions.id, competitions.price, competitions.coachcost
FROM cart LEFT JOIN competitions ON competitions.id = cart.eventID
where cart.userID='123'
") or die(mysql_error());	

while($balance=mysql_fetch_assoc($balanceQ))
{
$total +=$balance['price'] + $balance['coachcost'];
}

// get previous payments
$historyQ=mysql_query("select * from account where userID='123' ");	
while($history=mysql_fetch_assoc($historyQ))
	{	
	$subtract +=$history['amount'];

	} 

free($balanceQ);
free($historyQ);

echo "$".($total - $subtract); //<<<<  PROBLEM

}

 

Any help?

Link to comment
https://forums.phpfreaks.com/topic/181480-solved-decimal-display/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.