<a href="add.php">Add</a>
<br><br>
<table border="">
 <tbody>
    <tr>
       <th>NIDN</th>
       <th>Nama</th>
       <th>Jabatan</th>
       <th>Program Studi</th>
       <th>Golongan</th>
       <th>Pendidikan</th>
       <th>Tahun Mulai S1</th>
       <th>Tahun Lulus S1</th>
       <th>Tahun Mulai S2</th>
       <th>Tahun Lulus S2</th>
       <th>Username</th>
       <th>Password</th>
       <th>Email</th>
    </tr>
    <?php
    include 'config.php';
    $a=mysqli_query($conn,"SELECT * FROM dosen");
    foreach ($a as $b)
    {
    ?>
    <tr>
       <td><?= $b['nidn']; ?></td>
       <td><?= $b['nama']; ?></td>
       <td><?= $b['jabatan']; ?></td>
       <td><?= $b['program_studi']; ?></td>
       <td><?= $b['golongan']; ?></td>
       <td><?= $b['pendidikan']; ?></td>
       <td><?= $b['mulai_s1']; ?></td>
       <td><?= $b['lulus_s1']; ?></td>
       <td><?= $b['mulai_s2']; ?></td>
       <td><?= $b['lulus_s2']; ?></td>
       <td><?= $b['username']; ?></td>
       <td><?= $b['password']; ?></td>
       <td><?= $b['email']; ?></td>
       <td>
            <a href="update.php?nidn=<?= $b['nidn']; ?>"><b><i>Edit</i></b></a> | 
            <a href="index.php?nidn=<?= $b['nidn']; ?>" onclick="return confirm('Are you sure?')"><b><i>Delete</i></b></a>
        </td>
    </tr>  
    <?php } ?>                          
 </tbody>
</table>


<?php

if(isset($_GET['nidn']))
{
    $nidn=$_GET['nidn'];
    $sql="DELETE FROM dosen WHERE nidn='$nidn'";
    if($conn->query($sql) === false)
    { // Jika gagal meng-insert data tampilkan pesan dibawah 'Perintah SQL Salah'
      trigger_error('Wrong SQL Command: ' . $sql . ' Error: ' . $conn->error, E_USER_ERROR);
    } 
    else 
    { // Jika berhasil alihkan ke halaman tampil.php
      echo "<script>alert('Delete Success!')</script>";
      echo "<meta http-equiv=refresh content=\"0; url=index.php\">";
    }
}

?>