Thank you for all the examples and help for the running totals. Apparently I have missed something:
<?php
include 'connect.php';
$tdebit=0;
$tcredit=0;
$sql = <<<SQL
SELECT ...., ($tdebit=$tdebit+debit) AS tdebit,
($tcredit=$tcredit+credit) AS tcredit
FROM accounting
SQL;
if(!$result = $db->query($sql)){
die('There was an error running the query [' . $db->error . ']');
}
$items = array();
while($row = $result->fetch_assoc()){
array_push($items, $row);
}
echo json_encode($items);
mysqli_close($con);
?>
The result is 1 if a value in the field (credit/debit) and 0 if the value is zero. Any 'SET' or ':=' is not supported, the query is just not executed.
Thanks for any help, JPB