Advertisement
Guest User

stock

a guest
Nov 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <div class="jumbotron">
  2. <div class="container">
  3. <h2>Data Barang</h2>
  4.  
  5. <table width="99%" class="table table-bordered" id="mytable">
  6. <thead>
  7. <th >No</th>
  8. <th>Nama Barang</th>
  9. <th>Jumlah</th>
  10. <th>Satuan</th>
  11. </thead>
  12.  
  13. <?php
  14. $host="localhost";
  15. $user="root";
  16. $pass="";
  17. $data="sislap";
  18. $link=new mysqli($host,$user,$pass,$data);
  19.  
  20. if ($link->connect_error) {
  21. die("Koneksi Gagal : " . $link->connect_error);
  22. }
  23. $tabel = 'bm';
  24.  
  25. ?>
  26.  
  27. <?php
  28. $query = "SELECT DISTINCT brg FROM $tabel"; // QUERY UNTUK MENGUMPULKAN SEMUA NAMA BARANG
  29. if ($result = $link->query($query))
  30. {
  31. /* fetch object array */
  32. while ($crud_asanoer = $result->fetch_array(MYSQLI_ASSOC))
  33. {
  34. $brgx = $crud_asanoer['brg'];
  35. // //////////QUERY UNTUK PENJUMLAH QTY BARANG
  36. $query = "SELECT SUM(qty) AS total FROM $tabel Where brg='$brgx'; ";
  37. /////////////////////////////////////////////////
  38. $xresult = $link->query($query);
  39. $crud_x = $xresult->fetch_array(MYSQLI_ASSOC);
  40. $tqty = $crud_x['total'];
  41. $xresult->close();
  42. echo $brgx." = ".$tqty."<br/>";
  43. }
  44. /* free result set */
  45. $result->close();
  46. }
  47.  
  48. ?>
  49. </table>
  50. </div>
  51. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement