Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2. /*
  3.   nama file     : list_mhs.php
  4.   tgl pembuatan : 01 April 2019
  5.   author        : hendi
  6.   fungsi        : menampilkan seluruh data mahasiswa di dalam tabel
  7. */
  8.  
  9. $judul = "List Mahasiswa";
  10. include "koneksi.php";
  11. ?>
  12. <!DOCTYPE html>
  13. <html lang="en">
  14. <head>
  15.   <title><?php echo $judul; ?></title>
  16.   <meta charset="utf-8">
  17.   <meta name="viewport" content="width=device-width, initial-scale=1">
  18.   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  19.   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  20.   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  21.   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
  22. </head>
  23. <body>
  24.  
  25. <div class="container">
  26.   <h2><?php echo $judul; ?></h2>            
  27.   <table class="table table-striped">
  28.     <thead class="thead-dark">
  29.  
  30.       <tr>
  31.         <th>No</th>
  32.         <th>NIM</th>
  33.         <th>Nama Lengkap</th>
  34.         <th>Jenis Kelamin</th>
  35.       </tr>
  36.     </thead>
  37.     <tbody>
  38.     <?php
  39.       $strSQL = "SELECT * FROM mahasiswa";
  40.       $hasil = mysqli_query($koneksi,$strSQL);
  41.    
  42.       $i=0;
  43.       while ($baris = mysqli_fetch_assoc($hasil)) {
  44.         $i++;
  45.     ?>
  46.       <tr>
  47.         <td><?php echo $i; ?></td>
  48.         <td><?php echo $baris["nim"]; ?></td>
  49.         <td><?php echo $baris["nama"]; ?></td>
  50.         <td>
  51.         <?php
  52.           $jkel = $baris["jenis_kelamin"];
  53.           $str_jkel = ($jkel == "P" ? "Perempuan" : "Laki-laki");
  54.           echo $str_jkel;
  55.         ?>            
  56.         </td>
  57.       </tr>
  58.     <?php      
  59.       }
  60.     ?>    
  61.     </tbody>
  62.   </table>
  63. </div>
  64.  
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement