Du gör fel. Du kan få summan genom MySql-satsen själv.
Använd den samlade funktionen summa tillsammans med gruppera efter sats.
Så här,
SELECT DebitAccount,sum(Account) from 2_1_journal group by DebitAccount
Din fullständiga kod:
$query = " SELECT DebitAccount,sum(Account) as Total from 2_1_journal group by DebitAccount";
$sql = $db->prepare($query);
$sql->execute();
$data = $sql->fetchAll(PDO::FETCH_ASSOC);
foreach($data as $result){
if(strlen($result['Total']) > 0 ) {
echo "DebitAccount ". $result['DebitAccount']. "Total is: ". $result['Total']. "<br>";
print_r (array_sum($result));
}
}