Advertisement
Guest User

new

a guest
Nov 12th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <div class="jumbotron">
  2. <div class="container">
  3. <h2>Data Barang</h2>
  4.  
  5. <?php
  6. $host="localhost";
  7. $user="root";
  8. $pass="";
  9. $data="sislap";
  10. $link=new mysqli($host,$user,$pass,$data);
  11.  
  12. if ($link->connect_error) {
  13. die("Koneksi Gagal : " . $link->connect_error);
  14. }
  15. $tabel = 'bm';
  16.  
  17. ?>
  18.  
  19.  
  20. <table width="99%" class="table table-bordered" id="mytable">
  21. <thead>
  22. <th >No</th>
  23. <th>Nama Barang</th>
  24. <th>Jumlah</th>
  25. </thead>
  26.  
  27. <?php
  28. $no = 0;
  29. $query = "SELECT DISTINCT brg FROM $tabel"; // QUERY UNTUK MENGUMPULKAN SEMUA NAMA BARANG
  30. if ($result = $link->query($query))
  31. {
  32. /* fetch object array */
  33. while ($sql = $result->fetch_array(MYSQLI_ASSOC))
  34. {
  35. $brgx = $sql['brg']; //////////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. $no++;
  48. ?>
  49.  
  50. <tr>
  51. <td> <?php echo $no; ?></td>
  52. <td> <?php echo $brgx; ?></td>
  53. <td> <?php echo $tqty; ?></td>
  54. </tr>
  55.  
  56. </table>
  57. </div>
  58. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement