Location: PHPKode > projects > Gsys > includes/display_balance.php
<?php
    //display_balance.php

    //This outputs the current user's balance - output is float, red if negative, default if not.
    //IE:  if current user's balance is +50, including this will output "50" (no quotes obviously)
    //      if current user's balance is -75, including this will output "-75" in RED font.

    include '../includes/db.php';
   // session_start();

    $user = $_SESSION['current_user'];
    $pin_tmp = $_SESSION['pin_num'];

    $sql_bal = "SELECT brothers.pin_num, financial.pin_num, financial.amount, SUM(financial.amount) AS balance FROM financial INNER JOIN brothers ON financial.pin_num = brothers.pin_num WHERE financial.pin_num = '$pin_tmp' GROUP BY financial.pin_num";
    $sql_bal_result = mysql_query($sql_bal,$connection) or die(mysql_error());
    $bal_row = mysql_fetch_array($sql_bal_result);
    $balance = $bal_row['balance'];

    if($balance < 0)
        echo "<b><font color=\"red\">$balance</font></b>";
    else
        echo "<b>$balance</b>";

?>
Return current item: Gsys