Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. <?php
  2. include 'config.php';
  3. ?>
  4.  
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <title>Data CRUD Pancaker</title>
  9. <link rel="stylesheet" type="text/css" href="style.css">
  10. </head>
  11. <body>
  12. <center><h1>Data Para Pancaker 2019</h1></center>
  13. <left><a href="input.php">(+) Data Pancaker</a></left>
  14. <br/>
  15. <table class="zebra-table" border="1">
  16. <tr>
  17. <th>Id</th>
  18. <th>Nama</th>
  19. <th>Username</th>
  20. <th>Password</th>
  21. <th>Email</th>
  22. <th>Tindakan</th>
  23. </tr>
  24. <?php
  25. // query untuk menampilkan secara urut ID
  26. $query = "SELECT * FROM nama_pancaker ORDER BY id ASC";
  27. $result = mysqli_query($db, $query);
  28.  
  29. //pengecekan error pada query
  30. if(!$result){
  31. die ("query error: ".mysqli_errno($db).
  32. " - ".mysqli_error($db));
  33. }
  34.  
  35. $no = 1; //variabel agar sesuai nomor urut
  36. // kemudian ditampilkan dengan perulangan while
  37. while($data = mysqli_fetch_assoc($result))
  38. {
  39. // mencetak / menampilkan data
  40. echo "<tr>";
  41. echo "<td>$no</td>"; //menampilkan nomor
  42. echo "<td>$data[nama]</td>"; //menampilkan nama
  43. echo "<td>$data[username]</td>"; //menampilkan username
  44. echo "<td>$data[password]</td>"; //menampilkan password
  45. echo "<td>$data[email]</td>"; //menampilkan email
  46.  
  47. // membuat link untuk mengedit dan menghapus data
  48.  
  49. echo '<td>
  50. <a href="edit.php?id='.$data['id'].'">Edit</a> /
  51. <a href="hapus.php?id='.$data['id'].'"
  52. onclick="return confirm(\'Anda yakin akan hapus data?\')">Hapus</a>
  53. </td>';
  54. echo "</tr>";
  55. $no++;
  56. }
  57. ?>
  58. </table>
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement