<?php

$logged_user = get_logged_user();
if ($logged_user == 0) {
    header('Location: index.php');
}
$overall_balance = 0;
$closed_wallets = get_closed_wallets($logged_user);
foreach ($closed_wallets as $wallet) {
    $overall_balance = $overall_balance + bilance($wallet['id']);
}
$savings_from_db = get_savings($logged_user);
?>
<div style="float:left;">
    <h1 style="margin:0px;">Oszczędności</h1>
</div>
<div style="float:right; margin-top:15px;">
    Aktualny bilans:
    <span class="bigger <?php 
echo get_class_by_bilance_include_white(bilance($overall_balance));
?>
">
    <?php 
echo number_format($overall_balance - $savings_from_db['amount_out'], $decimals = 2, $dec_point = '.', $thousands_sep = '');
?>
 PLN
    </span>
</div>
<div style="clear:both;"></div>

<hr class="full" />
Beispiel #2
0
function get_savings($user_id)
{
    $query = "SELECT * FROM savings WHERE us_id = " . $user_id;
    $result = mysql_query($query);
    while ($row = mysql_fetch_array($result)) {
        return $row;
    }
    //if won't return any, means that it doesn't exists
    $query = "INSERT INTO savings SET amount_out = 0, us_id = " . $user_id;
    $result = mysql_query($query);
    get_savings($user_id);
}