Search code examples
phpsubtraction

Subtracting DB values via php


I am trying to subtract values of a db table $activationFee from a users total balance . How may i add the subtraction in the code below:

<div class="number">
    <strong>
        <?php echo $settings->currency; ?>
        <?php BalanceSystem($user_id); ?>
    </strong>
</div>
function BalanceSystem($user_id){
 $user_bank = DB::table('bank')->where('userid', $user_id)->first();
 echo $user_bank->balance;
}

Can someone please point me in the right direction?

I tried <?php BalanceSystem($user_id) - $activationFee ; ?> but did not work ... hides


Solution

  • This is how I managed to solve it:

        function BalanceSystem($user_id){
          $user_bank = DB::table('bank')->where('userid', $user_id)->first();
          $total = $user_bank->balance - 100;
          echo $total;
        }