Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'db.php';
- $query = "
- SELECT items.*, categories.name AS category_name
- FROM items
- LEFT JOIN categories ON items.category_id = categories.id
- ";
- $result = mysqli_query($conn, $query);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Inventory</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
- </head>
- </html>
- <body>
- <h1>Daftar Barang</h1>
- <a href="create.php" class="btn btn-primary mb-3">Tambah Barang</a>
- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
- <table class="table table-bordered">
- <thead>
- <tr>
- <th>Nama Barang</th>
- <th>Kategori</th>
- <th>Jumlah</th>
- <th>Harga</th>
- <th>Aksi</th>
- </tr>
- </thead>
- <tbody>
- <?php while ($row = mysqli_fetch_assoc($result)): ?>
- <tr>
- <td><?= htmlspecialchars($row['name']) ?></td>
- <td><?= htmlspecialchars($row['category_name']) ?: 'Tanpa Kategori' ?></td>
- <td><?= $row['quantity'] ?></td>
- <td><?= $row['price'] ?></td>
- <td>
- <a href="edit.php?id=<?= $row['id'] ?>">Edit</a>
- <a href="delete.php?id=<?= $row['id'] ?>" onclick="return confirm('Yakin ingin menghapus?')">Hapus</a>
- </td>
- </tr>
- <?php endwhile; ?>
- </tbody>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement