Advertisement
Guest User

anu

a guest
Dec 14th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <?php
  2. $table = 'tb_pindah';
  3. $option = '';
  4.  
  5. function getData($table){
  6. $servername = "localhost";
  7. $username = "root";
  8. $password = "";
  9. $db = "db_pindah";
  10. $conn = new mysqli($servername, $username, $password, $db);
  11.  
  12. $query = mysqli_query($conn,"SELECT * FROM {$table};");
  13. if($query){
  14. $data = array();
  15. while($row = mysqli_fetch_assoc($query)){
  16. $data[] = $row;
  17. }
  18. return $data;
  19. } else {
  20. return mysqli_error($this->db);
  21. }
  22. }
  23. ?>
  24.  
  25. <div class="col-lg-6">
  26. <div class="panel panel-default">
  27. <div class="panel-heading">
  28. Kategori
  29. </div>
  30. <!-- /.panel-heading -->
  31. <div class="panel-body">
  32. <div class="table-responsive">
  33. <table class="table">
  34. <thead>
  35. <tr>
  36. <th>No</th>
  37. <th>Kategori</th>
  38. <th>Action</th>
  39.  
  40. </tr>
  41. </thead>
  42. <tbody>
  43. <?php
  44.  
  45. //$namaTbl = "tb_pindah";
  46. $isiFungsi = getData($table); //get the result array
  47.  
  48. foreach($isiFungsi as $datanya) { //loop the array
  49. ?>
  50. <tr class="success">
  51. <td><?php echo $datanya['id'] ;?></td>
  52. <td><?php echo $datanya['nama'] ;?></td>
  53. <td class="center">
  54. <a class="" href="?p=home">Delete</a>
  55. </td>
  56. </tr>
  57. <?php }?>
  58. </tbody>
  59. </table>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement