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
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?

Link to comment
Share on other sites

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.

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.