Advertisement
dekikurnia

Untitled

Sep 4th, 2017
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Baojili</title>
  5.     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
  6.     <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
  7. </head>
  8. <body>
  9. <?php include_once ("manajer.php"); ?>
  10.  <div class="container">
  11.     <h1 align="center">Total Stock per Item</h1>
  12.     <br/>
  13.     <table id="dataTables" class="table table-bordered table-striped" cellspacing="0" width="100%">
  14.         <thead>
  15.             <tr>
  16.                 <th>NO.</th>
  17.                 <th>Kode Barang</th>
  18.                 <th>Size</th>
  19.                 <th>Total Stok</th>
  20.                 <th>Nama Lokasi</th>
  21.                 <th>Stok</th>
  22.             </tr>
  23.         </thead>
  24.        
  25.         <tbody>
  26.             <?php
  27.             $conn = new mysqli("localhost", "root", "BiN4iNforMaTIka33", "baojili");
  28.             if ($conn->connect_errno) {
  29.                 echo "Failed to connect to MySQL: " . $conn->connect_error;
  30.             }
  31.            
  32.             $no = 1;
  33.             $res = $conn->query("SELECT t_item.ItemID, t_item.Code, t_item.Size, SUM( Stock ) AS TotalStock, group_concat(t_location.Name) as Name, group_concat(t_stock.Stock) as Stock
  34. FROM t_stock
  35. LEFT JOIN t_location ON t_stock.LocationID = t_location.LocationID
  36. LEFT JOIN t_item ON t_stock.ItemID = t_item.ItemID
  37. GROUP BY ItemID");
  38.             while($row = $res->fetch_assoc()){
  39.                 echo '
  40.                 <tr>
  41.                     <td>'.$no.'</td>
  42.                     <td>'.$row['Code'].'</td>
  43.                     <td>'.$row['Size'].'</td>
  44.                     <td>'.$row['TotalStock'].'</td>
  45.                                        <td>'.$row['Name'].'</td>
  46.                                        <td>'.$row['Stock'].'</td>
  47.                 </tr>
  48.                 ';
  49.                 $no++;
  50.             }
  51.             ?>
  52.         </tbody>
  53.     </table>
  54.     </div>
  55.     <script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
  56.     <script src="//cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>
  57.     <script>
  58.     $(document).ready(function() {
  59.         $('#dataTables').DataTable();
  60.     } );
  61.     </script>
  62. </body>
  63. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement