Guest User

Untitled

a guest
Oct 22nd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. include('koneksi.php');
  3. if (isset($_POST['cari'])){
  4. $tampil_stok="select * from barang where nama_barang LIKE '%".$_POST['nama']."%'";
  5. }else{
  6. $tampil_stok="SELECT
  7. `barang_keluar`.`qty`,
  8. `barang_masuk`.`qty` AS `qty1`,
  9. `barang`.`qty` AS `qty2`,
  10. `barang`.`harga` AS `harga2`,
  11. `barang_masuk`.`no_transaksi`,
  12. `barang_keluar`.`no_transaksi` AS `no_transaksi1`,
  13. `barang`.`nama_barang`
  14. FROM
  15. `barang`
  16. INNER JOIN `barang_masuk` ON `barang_masuk`.`id_barang` = `barang`.`id_barang`
  17. INNER JOIN `barang_keluar` ON `barang_keluar`.`id_barang` =
  18. `barang`.`id_barang`";
  19. }
  20. $proses=mysql_query($tampil_stok);
  21. include('header.php');
  22. ?>
  23. <form method="post">
  24. <input type="text"name="nama"/>
  25. <input type="submit"name="cari"/>
  26. </form>
  27. <table border="1">
  28. <tr>
  29. <td>Nama Barang</td>
  30. <td>stok</td>
  31. <td>qty masuk</td>
  32. <td>qty keluar</td>
  33. <td>saldo</td>
  34. </tr>
  35. <?php
  36. while ($data=mysql_fetch_array($proses)){?>
  37. <tr>
  38. <td><?php echo $data['nama_barang'];?></td>
  39. <td><?php echo $data['qty'];?></td>
  40. <td><?php echo $data['qty1'];?></td>
  41. <td><?php echo $data['qty2'];?></td>
  42. <?php
  43. $stok=$data['qty'];
  44. $keluar=$data['qty1'];
  45. $masuk=$data['qty2'];
  46. $saldo=$stok+$masuk-$keluar;
  47. ?>
  48.  
  49. <td><?php echo $saldo;?></td>
  50. </tr>
  51. <?php } ?>
  52. </table>
Add Comment
Please, Sign In to add comment