Advertisement
oimtrust

index_crud-pdo-oop

Dec 28th, 2016
2,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.29 KB | None | 0 0
  1. <?php
  2.     require_once 'app/model/class.bio.php';
  3.  
  4.     $auth_bio   = new Biodata();
  5.  
  6.     //Untuk menampilkan data di tabel
  7.     $stmt = $auth_bio->runQuery("SELECT * FROM biodata");
  8.     $stmt->execute();
  9.  
  10.     $result = null;
  11.     if ($stmt->rowCount() == 0) {
  12.     }
  13.     else {
  14.         while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  15.             $result[]   = "<td>".$row['nama']."</td><td>".$row['phone']."</td><td>".$row['alamat']."</td><td>
  16.                                                                    <a class='btn btn-info' href='bio-edit.php?edit_ibio=".$row['id_bio']."'><span class='glyphicon glyphicon-edit'></span> Edit</a>
  17.                                                                    <a class='btn btn-danger' href='?delete_ibio=".$row['id_bio']."'><span class='glyphicon glyphicon-remove-circle'></span> Delete</a>
  18.                                                                </td>";
  19.         }
  20.     }
  21.  
  22.     //Eksekusi untuk menghapus data
  23.     if (isset($_GET['delete_ibio'])) {
  24.         try {
  25.             if ($auth_bio->deleteBio($ibio)) {
  26.                 $auth_bio->redirect('index.php?deleted');
  27.             }
  28.         } catch (PDOException $e) {
  29.             $e->getMessage();
  30.         }
  31.     }
  32.      
  33.     //Untuk menampilkan view (Sebelumnya telah kita buat)
  34.     include 'app/view/header.php';
  35.     include 'app/view/menu.php';
  36.     include 'app/view/index.php';
  37.     include 'app/view/footer.php';
  38.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement