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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.