How to handle dynamic data like php replace data variable, on datatable server side

How to handle dynamic data like php replace data variable, on datatable server side

Rendy07Rendy07 Posts: 1Questions: 0Answers: 0

I use datatable with looping php like be the below, but this condition not work on datatable server side.

**Current php looping **

$saldo = 5000;
if ( $result ) { while($transaksi = mysqli_fetch_array($result) ) {
            $saldo = $saldo + $transaksi['amount'];
        ?>
        <tr class="<?php echo $transaksi['type']; ?>" id="trans_<?php echo $transaksi['id']; ?>">
            <td class="right"><?php echo uang$saldo; ?></td>
        </tr>
<?php } } ?>

Server side

array(
        'db'        => '`trans`.`amount`',
        'dt'        => 'view_td6_saldo',
        'formatter' => function( $d, $row ) use ( $saldo ) {
            $saldo = $saldo + $d;
            return uang($saldo,false);
        },
        'field' => 'amount'
    ),

If amount[0] = 200; amount [1] = 300; and amount [2] = 700;
so saldo[0] = 5200; saldo[1] = 5500; and saldo[1] = 6200;
but if i use datatable server side, the the result for saldo[0] = 5200; saldo[1] = 5300; and saldo[1] = 5700;

This discussion has been closed.