Jump to content

Working out remaining balance.


Exoon

Recommended Posts

Hello,

 

Im making a little script to keep track on how much people have currently earnt on my site.

 

I have everything work but i can't figure out how to work out the current balance

 

 

At the moment ive got:

 

$currentbalance = $row['totalpaid'] - $row['points']; 

 

Which works untill the points becomes more then the total paid then it starts going in minus.

 

Im sure there's a simple fix but i just can't think of a way.

 

Any help would be great.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/237876-working-out-remaining-balance/
Share on other sites

If it's just a matter of displaying 0 when the $currentbalance drops below 0, use

 

$currentbalance = max($row['totalpaid'] - $row['points'], 0); 

 

But more importantly, why would the points be negative in the first place? Is your calculations correct?

Im not really sure now ive confused myself.

 

Im trying to show How much has been paid and how is remaining

 

So if they've earnt 5.00 and they request 4.50 i want the current balance to then show 0.50

 

Ive got Points field which contains the total money theyve earnt(including what theyve been paid), and ive got totalpaid which contains the total amount theyve been paid.

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.