Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $table = 'tb_pindah';
- $option = '';
- function getData($table){
- $servername = "localhost";
- $username = "root";
- $password = "";
- $db = "db_pindah";
- $conn = new mysqli($servername, $username, $password, $db);
- $query = mysqli_query($conn,"SELECT * FROM {$table};");
- if($query){
- $data = array();
- while($row = mysqli_fetch_assoc($query)){
- $data[] = $row;
- }
- return $data;
- } else {
- return mysqli_error($this->db);
- }
- }
- ?>
- <div class="col-lg-6">
- <div class="panel panel-default">
- <div class="panel-heading">
- Kategori
- </div>
- <!-- /.panel-heading -->
- <div class="panel-body">
- <div class="table-responsive">
- <table class="table">
- <thead>
- <tr>
- <th>No</th>
- <th>Kategori</th>
- <th>Action</th>
- </tr>
- </thead>
- <tbody>
- <?php
- //$namaTbl = "tb_pindah";
- $isiFungsi = getData($table); //get the result array
- foreach($isiFungsi as $datanya) { //loop the array
- ?>
- <tr class="success">
- <td><?php echo $datanya['id'] ;?></td>
- <td><?php echo $datanya['nama'] ;?></td>
- <td class="center">
- <a class="" href="?p=home">Delete</a>
- </td>
- </tr>
- <?php }?>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement