Advertisement
ridyko

index.php ( Cara CRUD )

Feb 1st, 2022
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php
  2. require_once("koneksi.php");
  3.  
  4. $sql = "SELECT * FROM tbl_mahasiswa";
  5. $result = $conn->query($sql);  
  6. $conn->close();    
  7. ?>
  8. <html>
  9. <head>
  10.     <link href="style.css" rel="stylesheet" type="text/css" />
  11.     <title>QuestKomputer - CRUD Mahasiswa</title>
  12. </head>
  13. <body>
  14. <h1>CRUD PHP MySQLi questkomputer.com</h1>
  15.     <div class="button_link"><a href="input.php">Input Data</a></div>
  16.     <table class="tbl-qa"> 
  17.         <thead>
  18.              <tr>
  19.                 <th class="table-header" wnimmhsth="20%">NIM</th>
  20.                 <th class="table-header" wnimmhsth="20%">Nama</th>
  21.                 <th class="table-header" wnimmhsth="20%"> Alamat </th>
  22.                 <th class="table-header" wnimmhsth="20%"> telepon </th>
  23.                 <th class="table-header" wnimmhsth="20%"> Jurusan </th>
  24.                 <th class="table-header" wnimmhsth="20%" colspan="2">Aksi</th>
  25.               </tr>
  26.         </thead>
  27.         <tbody>    
  28.             <?php
  29.                 if ($result->num_rows > 0) {       
  30.                     while($row = $result->fetch_assoc()) {
  31.             ?>
  32.             <tr class="table-row" id="row-<?php echo $row["nimmhs"]; ?>">
  33.                 <td class="table-row"><?php echo $row["nimmhs"]; ?></td>
  34.                 <td class="table-row"><?php echo $row["namamhs"]; ?></td>
  35.                 <td class="table-row"><?php echo $row["alamatmhs"]; ?></td>
  36.                 <td class="table-row"><?php echo $row["teleponmhs"]; ?></td>
  37.                 <td class="table-row"><?php echo $row["jurusanmhs"]; ?></td>
  38.                 <!-- action -->
  39.                 <td class="table-row" colspan="2"><a href="edit.php?nimmhs=<?php echo $row["nimmhs"]; ?>" class="link"><img title="Edit" src="icon/edit.png"/></a> <a href="hapus.php?nimmhs=<?php echo $row["nimmhs"]; ?>" class="link"><img name="delete" nimmhs="delete" title="Delete" onclick="return confirm('Yakin akan di Hapus?')" src="icon/delete.png"/></a></td>
  40.             </tr>
  41.             <?php
  42.                     }
  43.                 }
  44.             ?>
  45.         </tbody>
  46.     </table>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement