<?php
function getBalance($acctn){
global $conn;
$acc_bal = $conn->query("select accnt_nmb, sum(amt_cred) as totalCredit, sum(amt_dep) as totalDebit from credit_info where accnt_nmb = '$acctn' group by accnt_nmb") or die($conn->error);	

if (!$acc_bal->num_rows) {
	// code...
	return 0; 
}
$row_acc = $acc_bal->fetch_assoc();
return $row_acc['totalCredit'] - $row_acc['totalDebit']; 
}

$selCredit = $conn->query("select * from credit_info where accnt_nmb = '" . $rowUser['acct_nmb'] . "' order by 	transact_id DESC") or die($conn->error);	
if($selCredit->num_rows){
$rowCredit = $selCredit->fetch_assoc(); 

$trans_date = $rowCredit['dat_pay'];
if($rowCredit['trans_type'] =="Credit"){
$amt_trans = $rowCredit['amt_cred'];
}else{
$amt_trans = $rowCredit['amt_dep'];
}

$trans_stat = $rowCredit['trans_type'];
}else{
$trans_date = "Nill";
$amt_trans = "Nill";
$trans_stat = "Nill";
}
?>