<?php include("inc_header.php") ?>
<?php 

$sukses = "";
$katakunci = (isset($_GET['katakunci'])) ? $_GET['katakunci'] : "";
if (isset($_GET['op'])) {
    $op = $_GET['op'];
} else {
    $op = "";
}
if ($op == 'delete') {
    $id = $_GET['id'];
    $sql1   = "delete from halaman where id = '$id'";
    $q1     = mysqli_query($koneksi, $sql1);
    if ($q1) {
        $sukses     = "Berhasil hapus data";
    }
}
?>
<h1>Halaman Admin</h1>
<!-- <p>
    <a href="halaman_input.php">
        <input type="button" class="btn btn-primary" value="Buat Halaman Baru" />
    </a>
</p> -->
<?php
if ($sukses) {
?>
    <div class="alert alert-primary" role="alert">
        <?php echo $sukses ?>
    </div>
<?php
}
?>

 
<div class="btn-group mb-4" role="group" aria-label=""> 
   <?php 
                        foreach ($datahalaman as $key) {
                            echo '
  <button type="button" class="btn btn-secondary" id="'.$key['master_menu'].'" >'.$key['nama_menu'].'</button>
                      
                            ';
                        }
    ?>
</div>


 
<div id="tbhalaman"></div>
<?php include("inc_footer.php") ?>

  <?php 
                        foreach ($datahalaman as $key) {
                            echo '

                            <script type="text/javascript">
    
    $("#'.$key['master_menu'].'").click(function(){ 
           $.ajax({
                type: "POST", 
                url: "table/halaman.php", 
                data: "page='.$key['master_menu'].'",
 
                success: function(response){
              console.log(response); 
              $("#tbhalaman").html(response); 

             }
       }); 
});
</script>
                            ';
                        }
    ?>


