Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="jumbotron">
- <div class="container">
- <h2>Data Barang</h2>
- <table width="99%" class="table table-bordered" id="mytable">
- <thead>
- <th >No</th>
- <th>Nama Barang</th>
- <th>Jumlah</th>
- <th>Satuan</th>
- </thead>
- <?php
- $host="localhost";
- $user="root";
- $pass="";
- $data="sislap";
- $link=new mysqli($host,$user,$pass,$data);
- if ($link->connect_error) {
- die("Koneksi Gagal : " . $link->connect_error);
- }
- $tabel = 'bm';
- ?>
- <?php
- $query = "SELECT DISTINCT brg FROM $tabel"; // QUERY UNTUK MENGUMPULKAN SEMUA NAMA BARANG
- if ($result = $link->query($query))
- {
- /* fetch object array */
- while ($crud_asanoer = $result->fetch_array(MYSQLI_ASSOC))
- {
- $brgx = $crud_asanoer['brg'];
- // //////////QUERY UNTUK PENJUMLAH QTY BARANG
- $query = "SELECT SUM(qty) AS total FROM $tabel Where brg='$brgx'; ";
- /////////////////////////////////////////////////
- $xresult = $link->query($query);
- $crud_x = $xresult->fetch_array(MYSQLI_ASSOC);
- $tqty = $crud_x['total'];
- $xresult->close();
- echo $brgx." = ".$tqty."<br/>";
- }
- /* free result set */
- $result->close();
- }
- ?>
- </table>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement