<h4 class="text-light"><b>Dashboard</b></h4>
<div class="row">
    <div class="col-md-12">
        <div class="card shadow p-2">
            <table class="table table-striped table-selected" id="myTable">
                <thead>
                    <tr>
                        <th>KRW</th>
                        <th>Jumlah Penduduk</th>
                        <th>Jumlah KK</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $TotPen = 0; $TotKK = 0?>
                    <?php $getKrw = $con->query("SELECT krw, COUNT(*) as jum FROM penduduk GROUP BY krw ORDER BY krw ASC");?>
                    <?php foreach($getKrw as $data){?>
                        <tr>
                            <td><?= $data['krw']?></td>
                            <td>
                                <a href="index.php?hal=penduduk&krw=<?= $data['krw']?>" class="btn btn-sm btn-warning">
                                    <?php $TotPen += $data['jum']?>
                                    <?= $data['jum']?>
                                </a>
                            </td>
                            <td>
                                <?php
                                    $getKK = $con->query("SELECT COUNT(*) AS jum FROM penduduk WHERE krw = '$data[krw]' and hubungan_keluarga = 'KK'")->fetch_assoc();
                                ?>
                                <?php $TotKK += $getKK['jum']?>
                                <?= $getKK['jum']?>
                            </td>
                            <td>
                                <a href="pages/print_kk.php?krw=<?= $data['krw']?>" class="btn btn-sm btn-warning">Print ALL KK</a>
                            </td>
                        </tr>
                    <?php }?>
                    <tfoot>
                        <tr>
                            <td><b>Total</b></td>
                            <td><b><?= $TotPen?></b></td>
                            <td><b><?= $TotKK?></b></td>
                            <td></td>
                        </tr>
                    </tfoot>
                </tbody>
            </table>
        </div>
    </div>
</div>