<?php

$connpans = mysqli_connect(‘localhost’,’user’,’pass’,’db’);
$sqlp=”select * from login_user”;
$resultp=mysqli_query($connpans,$sqlp);
$userdata=mysqli_fetch_assoc($resultp);
$wallet = $userdata[‘wallet’];

if ($userdata[‘wallet’] == “”) {
$balance = 0;
} else {
$balance = $userdata[‘wallet’]; ///output balance: 100.9872749837958
}

$stmt = $conn->prepare(“select sum(wallet) from login_user”);
$stmt->execute();
while ($row = $stmt->fetch()) {
echo $row[‘sum(wallet)’] + $balance;  ///output balance: 100.98
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *