Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81929

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

$
0
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;


Viewing all articles
Browse latest Browse all 81929

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>