<?php
include '../config.php';
function getAmount(){
$sql = "SELECT sum(amount) AS total
FROM transaction
WHERE updated_at > '1501525800000'
AND updated_at < '1504117800000'";
$sumresult = mysqli_query($con,$sql);
$sumrow=mysqli_fetch_assoc($sumresult);
return $sumrow['total'];
}
$total = getAmount();
echo $total;
?>
Hello There, I am new to PHP and I am getting the sum of all price in a particular month from my transaction table. But the value returned is empty, the query is working as well as the $total value is printed if I do not use function. But when I try to return value via function, nothing is printed. Help is really appreciated. Thanks in advance.