Skip to content

Instantly share code, notes, and snippets.

@creativefull
Forked from anonymous/Kategori.php
Last active September 4, 2016 15:36
Show Gist options
  • Save creativefull/fce0bc87dc676932c6f931e04ffe7c2d to your computer and use it in GitHub Desktop.
Save creativefull/fce0bc87dc676932c6f931e04ffe7c2d to your computer and use it in GitHub Desktop.
<script type="text/javascript">
$(".klik").click(function() {
console.log("Element di klik");
$(this).closest("tr").find(".sub").toggle();
})
</script>
<div class="container col-lg-12">
<div class="kotak">
<center><h1>KATEGORI</h1></center>
<a href=""><button class="tambah"><i class="fa fa-print"></i> CETAK</button></a>
<table width="100%" >
<tr>
<td>NO</td>
<td>KATEGORI</td>
</tr>
<?php
$no = 1 ;
foreach ($db -> tampilkategori() as $lihatkat){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><button id="show" class="klik">KLIK</button><?php echo $lihatkat['nama_kategori']; ?></td>
</tr>
<?php $idkat = $lihatkat['id_kategori']; ?>
<?php foreach ($db -> tampilsubkategori($idkat) as $lihatsubkat) {
?>
<tr>
<td>
</td>
<td>
<ul>
<li class="sub">
<?php echo $lihatsubkat['nama_subkat']; ?>
</li>
</ul>
</td>
</tr>
<?php
}
?>
<?php } ?>
</table>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment