<div class="row">
    <div class="col-xl-12">
        <div class="card border border-info">
            <div class="card-body">
            <h4 class="card-title"><i class="fas fa-plus"></i> Tambahkan Promosi Baru</h4>
                <form method="POST" action="config/add-promo.php" class="form-horizontal">
                        <button type="submit" class="btn btn-primary"><i class="fas fa-check"></i> Tambahkan Promosi</button>
                </form>
            </div>
        </div>
    </div>

        <?php
            $spromo = "SELECT * FROM promosi_blog ORDER BY promo_tgl DESC";
            $qpromo = mysqli_query($data, $spromo);

            if(mysqli_num_rows($qpromo) > 0) {

                $x2 = 1;
                $x3 = 1;

                while($fpromo = mysqli_fetch_assoc($qpromo)) {

                    $imgpromo = $fpromo['gambar_promo'];
                    $promo = $fpromo['promo_content'];
                    $tglpromo = $fpromo['promo_tgl'];
                    $idpromo = $fpromo['id'];

                    echo '<div class="col-xl-12">
                    <div class="card border border-info">
                        <form method="POST" action="config/update-promosi-text.php?row='.$idpromo.'" class="form-horizontal">
                            <div class="card-body position-relative">
                                    <h4 class="card-title"><i class="fas fa-dollar-sign"></i> Promo #'.$x2++.'</h4>
                                        <div style="position:absolute; right: 0; top: 0;"> 
                                            <a href="config/delete-promo.php?row='.$idpromo.'" class="btn btn-danger"><i class="fas fa-times"></i> Hapus Promo #'.$x3++.'</a>
                                        </div>
                                        <div class="clear-fix"></div>
                                        <div class="input-group my-3">
                                            <span class="input-group-text"><i class="fas fa-image"></i></span>
                                            <input type="text" name="img-promo" class="form-control" value="'.$imgpromo.'" placeholder="Link Gambar Utama Promosi.." required />
                                        </div>
                                        <img src="'.$imgpromo.'" width="500" alt="tidak ada gambar promo" /> <br />
                                        <small>'.$uploadgambar.'</small> <br />
                                        <small class="text-success font-weight-bold">Update pada : '.$tglpromo.'</small>
                                        <textarea class="editor" name="promo-page-text" style="height: 300px; width: 100%;">'.html_entity_decode($promo).'</textarea>
            
                                    <button type="submit" class="btn mt-3 btn-block btn-primary">Submit</button>
                                       
                                    </form>
                             </div>
                     </div>';
                }
            } else {
                echo 'tidak ada promo!!';
            }
        ?>

      


         
</div>




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