<div class="row">
        <div class="col-md-12">
                <div class="card border border-danger">
                    <form method="POST" action="config/add-prediksi.php" class="form-horizontal">
                        <div class="card-body">
                            <h4 class="card-title"><i class="mdi mdi-plus-circle"></i> Tambah Manual Prediksi</h4>
                            <div class="form-group row">

                                <label class="col-sm-3 text-right control-label col-form-label">Pilih Pasaran:</label>
                                <div class="col-sm-9">
                                        <select name="prepasaran" class="custom-select" required>
                                            <option value="">Belum Dipilih</option>
                                            <?php
                                                $spas = "SELECT * FROM pasaran_web";
                                                $qpas = mysqli_query($data, $spas);

                                                if(mysqli_num_rows($qpas) > 0) {
                                                    while($fpas = mysqli_fetch_assoc($qpas)) {
                                                        $pasran = $fpas['nama_pasaranweb'];
                                                        echo '<option class="text-capitalize" value="'.$pasran.'">'.$pasran.'</option>';
                                                    }
                                                }
                                            ?>
                                        </select>    
                                </div>

                            </div>
                            
                            <div class="card-body my-3">
                                <button type="submit" class="btn float-right btn-primary"><i class="mdi mdi-plus-circle"></i> Tambahkan Prediksi</button>
                            </div>
                    </form>
                </div>
        </div>

        <div class="col-xl-12">
        <div class="card border border-info">
        <div class="card-body">
                                <h5 class="card-title m-b-0"><i class="mdi mdi-dice-d20"></i> Semua Prediksi</h5>
                            </div>
                            <table id="prediksi-block" class="table font-weight-bold">
                                  <thead>
                                    <tr>
                                      <th scope="col">#</th>
                                      <th scope="col">Gambar</th>
                                      <th scope="col">Pasaran</th>
                                      <th scope="col">Tanggal</th>
                                      <th scope="col">Action</th>
                                    </tr>
                                  </thead>
                                  <tbody>

                                  <?php
                                    $spre = "SELECT DISTINCT prediksi_togel.* FROM prediksi_togel INNER JOIN pasaran_web ON pasaran_web.nama_pasaranweb = prediksi_togel.pasaran_prediksi ORDER BY DATE(prediksi_togel.tanggal_prediksi) DESC, pasaran_web.id";
                                    $qpre = mysqli_query($data, $spre);

                                        if(mysqli_num_rows($qpre) > 0) {
                                            $n = 1;
                                            while($fpre = mysqli_fetch_assoc($qpre)) {
                                                $pasaranpre = $fpre['pasaran_prediksi'];
                                                $tglpre = $fpre['tanggal_prediksi'];
                                                $idpre = $fpre['id'];

                                                echo '<tr>
                                                <th scope="row">'.$n++.'</th>
                                                <td><img class="rounded" src=" assets/images/icon-market/'.$pasaranpre.'.webp" width="100" /></td>
                                                <td class="text-capitalize">Prediksi Togel '.$pasaranpre.'</td>
                                                <td> '.date("d M Y | H:i:s", strtotime($tglpre)).'</td>
                                                <td><a href="config/delprediksi.php?row='.$idpre.'" class="btn btn-danger"><i class="fas fa-times"></i> Hapus Prediksi</a></td>
                                                </tr>
                                                ';

                                            }

                                        } else {

                                        }

                                    ?>


                                    

                                  </tbody>
                            </table>
         </div>

         
</div>

<?php
        if(!isset($_SESSION['nama_pengguna'])) {
        echo '<script>
        window.location.replace("/");
        </script>';
        }
    ?>