Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'headeradmin.php';
- include 'produk_list.php';
- $value = $_SESSION['user']['Id_Admin'];
- ?>
- <?PHP
- $Host = "localhost";
- $username = "root";
- $password = "";
- $database = "dbmonera";
- $koneksi = new mysqli( $Host, $username, $password, $database );
- if ($koneksi->connect_error){
- echo 'Gagal koneksi ke database';
- } else {
- //koneksi berhsil
- }
- // membuat query max
- $carikode = mysqli_query($koneksi, "select max(Id_Distribusi) from distribusi") or die (mysql_error());
- // menjadikannya array
- $datakode = mysqli_fetch_array($carikode);
- // jika $datakode
- if ($datakode) {
- $nilaikode = substr($datakode[0], 1);
- // menjadikan $nilaikode ( int )
- $kode = (int) $nilaikode;
- // setiap $kode di tambah 1
- $kode = $kode + 1;
- $kode_otomatis = "H".str_pad($kode, 4, "0", STR_PAD_LEFT);
- } else {
- $kode_otomatis = "H0001";
- }
- ?>
- <h3><span class="glyphicon glyphicon-briefcase"></span> Data Produk </h3>
- <input TYPE="button" class="btn btn-default" href="" onclick="history.go(-1);" value="Kembali">
- <form method="post" action="distribusi_do_simpan.php">
- <div>
- <table class="table">
- <tr>
- <td>Id Distribusi :</td>
- <td> <input type="text" class="form-control" name="id_distribusi" required value="<?php echo $kode_otomatis ?>"></td>
- </tr>
- <tr>
- <td>Nama Produk</td>
- <td>
- <?php foreach ($produk_dataok as $produk): ?>
- <div class="checkbox">
- <label><input type="checkbox" name="nama_produk[]" value="<?php echo $produk['Id_Produk'] ?>"><?php echo $produk['Nama_Produk'] ?></label>
- <?php endforeach ?>
- </td>
- </tr>
- <tr>
- <td>Jumlah :</td>
- <td><input type="text" class="form-control" name="total" required ></td>
- </tr>
- <tr>
- <td>Admin :</td>
- <td><input type="text" class="form-control" name="admin" required value="<?php echo $value;?>"></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" class="btn btn-info" value="Simpan">
- <a href="produk.php?halaman=" class="btn btn-danger"> Reset </a>
- <a href="produk.php?halaman=" class="btn btn-success"> Add More Produk </a> </td>
- </tr>
- </table>
- </div>
- </form>
- </form>
- <div class="box">
- <table id="provinsi" class="table table-bordered">
- <thead>
- <tr>
- <th width="10%">ID Produk</th>
- <th width="15%">Nama Produk</th>
- <th width="15%">Jumlah</th>
- <th width="10%">Admin</th>
- <th width="10%">Action</th>
- </tr>
- </thead>
- <tbody>
- <?php
- //Data mentah yang ditampilkan ke tabel
- mysql_connect('localhost', 'root', '');
- mysql_select_db('dbmonera');
- $sql = mysql_query("SELECT Produk.Id_Produk, produk.Nama_Produk, distribusi.Total, admin.Nama_Admin
- FROM produk, detail_distribusi, distribusi, admin
- WHERE produk.Id_Produk = detail_distribusi.Id_Produk AND detail_distribusi.Id_Distribusi = distribusi.Id_Distribusi AND distribusi.Id_Admin = admin.Id_Admin");
- $no = 1;
- while ($r = mysql_fetch_array($sql)) {
- ?>
- <tr align='left'>
- <td><?php echo $r['Id_Produk']; ?></td>
- <td><?php echo $r['Nama_Produk']; ?></td>
- <td><?php echo $r['Total']; ?></td>
- <td><?php echo $r['Nama_Admin']; ?></td>
- <td>
- <a href="produk_edit.php?id_produk=<?php echo $r['Id_Produk']; ?>" class="btn btn-edit">Edit</a>
- <a href="produk_delete.php?id_produk=<?php echo $r['Id_Produk']; ?>" class="btn btn-hapus" onclick="return confirm('anda yakin akan menghapus data?');">Hapus</a>
- </td>
- </tr>
- <?php
- $no++;
- }
- ?>
- </tbody>
- </table>
- </div>
- <?php include 'footeradmin.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement