-
Notifications
You must be signed in to change notification settings - Fork 0
/
balance.php
32 lines (27 loc) · 863 Bytes
/
balance.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
require_once("config/connection.php");
session_start();
if(!isset($_SESSION["login_user"]) && $_SESSION["login_user"]["role"]==3){
echo "<b> Access Denied<b>";
print_r($_SESSION["login_user"]."S");
die();
return;
}
$user=$_SESSION["login_user"];
$id=$user['id'];
$sql="SELECT SUM(amount) as a from transection where account_no=$id and mode='CREDIT'";
if(!$res=mysqli_query($conn,$sql)){
mysqli_error($conn);
}else{
$row=mysqli_fetch_assoc($res);
$credit=$row['a'];
$sql="SELECT SUM(amount) as a from transection where account_no=$id and mode='DEBIT'";
if(!$res=mysqli_query($conn,$sql)){
mysqli_error($conn);
}
$row=mysqli_fetch_assoc($res);
$debit=$row['a'];
$bal=$credit-$debit;
echo $bal;
}
?>