Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $search = isset($_GET["search"]) ? $_GET["search"] : false;
- $where = "";
- $search_url = "";
- if ($search) {
- $search_url = "&search=$search";
- $where = "WHERE barang.nama_barang LIKE '%$search%'";
- }
- ?>
- <div id="frame-tambah">
- <div id="left">
- <form action="<?php echo BASE_URL . "index.php"; ?>" method="GET">
- <input type="hidden" name="page" value="<?php echo $_GET["page"]; ?>" />
- <input type="hidden" name="module" value="<?php echo $_GET["module"]; ?>" />
- <input type="hidden" name="action" value="<?php echo $_GET["action"]; ?>" />
- <input type="text" name="search" value="<?php echo $search; ?>" />
- <input type="submit" value="Search" />
- </form>
- </div>
- <div id="right">
- <!-- button / link tambah data kategori -->
- <a href="<?php echo BASE_URL . "index.php?page=my_profile&module=barang&action=form"; ?>" class="tombol-action">+ Tambah Barang</a>
- </div>
- </div>
- <?php
- $pagination = isset($_GET["pagination"]) ? $_GET["pagination"] : 1;
- $data_per_halaman = 3;
- $mulai_dari = ($pagination - 1) * $data_per_halaman;
- // koneksi Database ke tabel
- $queryBarang = mysqli_query($koneksi, "SELECT barang.*, kategori.kategori FROM barang
- JOIN kategori ON barang.kategori_id = kategori.kategori_id
- $where LIMIT $mulai_dari, $data_per_halaman");
- // check tabel per row
- if (mysqli_num_rows($queryBarang) == 0) {
- echo "<h3>Maaf list menu belum tersedia</h3>";
- } else {
- echo "<table class='table-list'>";
- echo "<tr class='baris-title'>
- <th class='kolom-nomor'>No</th>
- <th class='kiri'>Nama Barang</th>
- <th class='tengah'>kategori</th>
- <th class='tengah'>Harga</th>
- <th class='tengah'>Status</th>
- <th class='tengah'>action</th>
- </tr>";
- $no = 1 + $mulai_dari;
- //melakukan perulangan dan mengeluarkan data table kategori ke dalam list tabel
- while ($row = mysqli_fetch_assoc($queryBarang)) {
- echo "<tr>
- <td class='kolom-nomor'>$no</td>
- <td class='kiri'>$row[nama_barang]</td>
- <td class='tengah'>$row[kategori]</td>
- <td class='tengah'>" . rupiah($row["harga"]) . "</td>
- <td class='tengah'>$row[status]</td>
- <td class='tengah'>
- <a class='tombol-action' href='" . BASE_URL . "index.php?page=my_profile&module=barang&action=form&barang_id=$row[barang_id]'>Edit</a>
- <a class='tombol-action' href='" . BASE_URL . "module/barang/action.php?button=delete&barang_id=$row[barang_id]'>Delete</a>
- </td>
- </tr>";
- $no++;
- }
- echo "</table>";
- $queryHitungBarang = mysqli_query($koneksi, "SELECT * FROM barang");
- pagination($queryHitungBarang, $data_per_halaman, $pagination, "index.php?page=my_profile&module=barang&action=list$search_url");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment