Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('koneksi.php');
- if (isset($_POST['cari'])){
- $tampil_stok="select * from barang where nama_barang LIKE '%".$_POST['nama']."%'";
- }else{
- $tampil_stok="SELECT
- `barang_keluar`.`qty`,
- `barang_masuk`.`qty` AS `qty1`,
- `barang`.`qty` AS `qty2`,
- `barang`.`harga` AS `harga2`,
- `barang_masuk`.`no_transaksi`,
- `barang_keluar`.`no_transaksi` AS `no_transaksi1`,
- `barang`.`nama_barang`
- FROM
- `barang`
- INNER JOIN `barang_masuk` ON `barang_masuk`.`id_barang` = `barang`.`id_barang`
- INNER JOIN `barang_keluar` ON `barang_keluar`.`id_barang` =
- `barang`.`id_barang`";
- }
- $proses=mysql_query($tampil_stok);
- include('header.php');
- ?>
- <form method="post">
- <input type="text"name="nama"/>
- <input type="submit"name="cari"/>
- </form>
- <table border="1">
- <tr>
- <td>Nama Barang</td>
- <td>stok</td>
- <td>qty masuk</td>
- <td>qty keluar</td>
- <td>saldo</td>
- </tr>
- <?php
- while ($data=mysql_fetch_array($proses)){?>
- <tr>
- <td><?php echo $data['nama_barang'];?></td>
- <td><?php echo $data['qty'];?></td>
- <td><?php echo $data['qty1'];?></td>
- <td><?php echo $data['qty2'];?></td>
- <?php
- $stok=$data['qty'];
- $keluar=$data['qty1'];
- $masuk=$data['qty2'];
- $saldo=$stok+$masuk-$keluar;
- ?>
- <td><?php echo $saldo;?></td>
- </tr>
- <?php } ?>
- </table>
Add Comment
Please, Sign In to add comment