Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang = "en">
- <head>
- <title>Studi Kasus</title>
- </head>
- <body>
- <?php
- $host='localhost';
- $username='root';
- $password='';
- $database='myweb';
- $conn = mysqli_connect($host, $username, $password, $database);
- if (!$conn){
- die("Connection Failed : ".mysqli_connect_error);
- }
- if(!isset($_GET['start'])) {
- $start = 0;
- } else {
- $start = $_GET['start'];
- }
- $data = mysqli_query($conn,"SELECT * FROM mahasiswa LIMIT $start, 5;") or die("Gagal :".mysqli_error());
- ?>
- <table align="center" border="1">
- <tr>
- <th width = "100">NIM</th>
- <th width = "100">Nama</th>
- <th width = "100">Alamat</th>
- <th width = "100">Data</th>
- </tr>
- <?php
- while ($rec=mysqli_fetch_row($data))
- {
- ?>
- <tr>
- <td>
- <a href="manage.php?nama=<?php echo $rec[1] ?>&alamat=<?php echo $rec[2]?>">
- <?php echo $rec[0] ?>
- </a>
- </td>
- <?php
- echo '<td>'.$rec[1].'</td>';
- echo '<td>'.$rec[2].'</td>';
- ?>
- <td>
- <button onclick = "var r = confirm('Hapus NIM <?php echo $rec[0]; ?>?'); if(r==true){ window.location.href='delete.php?nim=<?php echo $rec[0] ?>'; return r;} ">
- Hapus
- </button>
- </td>
- </tr>
- <?php
- }
- ?>
- </table>
- <?php
- $query = mysqli_query($conn, "SELECT * FROM mahasiswa");
- $num = mysqli_num_rows($query);
- if($num > 5) {
- ?>
- <a href = "index.php?start=0">Page 1</a>
- <a href = "index.php?start=5">Page 2</a>
- <?php
- $num = $num -5;
- }
- $startpage = 5;
- $page = 3;
- while($num > 5) {
- $startpage = $startpage+5;
- ?>
- <a href = "index.php?start=<?php echo $startpage ?>">Page <?php echo $page ?></a>
- <?php
- $page = $page + 1;
- $num = $num - 5;
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement