Tuesday, 5 September 2017

Codeigniter Penjumlahan Row Data Table


<table class="table table-bordered table-striped">
    <thead>
    <tr>
        <th>Jenis Produk dan atau Layanan</th>
        <th>Kategori Permasalahan</th>
        <th>Jumlah</th>
        <th>Selesai</th>
        <th>Tidak Selesai</th>
        <th>Dalam Proses</th>
    </tr>
    </thead>
    <tbody>
    <?php   foreach($dojk01->result() as $row) {
            $P1   +=$row->TOTAL;
            $P2   +=$row->DONE;
            $P3   +=$row->PROS;
    ?>
    <tr>
        <td align='left'><?php echo $row->JenisProduk;?> : <?php echo $row->Layanan;?></td>
        <td align='left'><?php echo $row->Kategori;?></td>
        <td align='center'><?php echo number_format($row->TOTAL,0);?></td>
        <td align='center'><?php echo number_format($row->DONE,0);?></td>
        <td align='center'><?php echo "0";?></td>
        <td align='center'><?php echo number_format($row->PROS,0);?></td>
    </tr>
    <?php } ?>
    <tr>
        <td align='center' colspan='2'><b>TOTAL</b></td>
        <td align='center'><b><?php echo $P1;?></b></td>
        <td align='center'><b><?php echo $P2;?></b></td>
        <td align='center'><b><?php echo "0";?></b></td>
        <td align='center'><b><?php echo $P3;?></b></td>
    </tr>
    </tbody>
</table>


2 comments:

  1. jika muncul error
    Message: Undefined variable: P1
    maka sisikan $P1=0; sebelum foreach($dojk01->result() as $row)

    ReplyDelete