Advertisement
Guest User

Untitled

a guest
May 27th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.62 KB | None | 0 0
  1. -------------------------------------- Table --------------------------------------
  2. <table id="data-table-buttons" class="table table-striped table-bordered">
  3.     <thead>
  4.         <tr>
  5.             <!--<th width="1%" data-orderable="false"></th>-->
  6.             <th class="text-nowrap">Id</th>
  7.             <th class="text-nowrap">Data</th>
  8.             <th class="text-nowrap">Loja</th>
  9.             <th class="text-nowrap">Produto</th>
  10.             <th class="text-nowrap">Qtde</th>
  11.             <th class="text-nowrap">Vlr. Unit.</th>
  12.             <th class="text-nowrap">Vlr. Total</th>
  13.         </tr>
  14.     </thead>
  15. </table>
  16. -------------------------------------- Script DataTable --------------------------------------
  17.  
  18. <script type="text/javascript" language="javascript">
  19.     $(document).ready(function() {
  20.         $('#data-table-buttons').DataTable( {
  21.             dom: 'Bfrtip',
  22.             buttons: [
  23.                 'copy', 'csv', 'excel', 'pdf', 'print'
  24.             ],
  25.             "processing": true,
  26.             "serverSide": true,
  27.             "ajax": {
  28.                 "url": "busca.php",
  29.                 "type": "POST"
  30.             },
  31.             "columns" : [ {
  32.                 "data" : "Id"
  33.             }, {
  34.                 "data" : "data"
  35.             }, {
  36.                 "data" : "loja"
  37.             }, {
  38.                 "data" : "produto"
  39.             },{
  40.                 "data" : "qtde"
  41.             },{
  42.                 "data" : "vlrunitario"
  43.             },{
  44.                 "data" : "vlrtotal"
  45.             }]            
  46.         } );
  47.     } );
  48. </script>
  49.  
  50. -------------------------------------- PHP --------------------------------------
  51. Aqui eu não estou conseguindo montar pra...
  52. RAW Paste Data
  53. -------------------------------------- Table --------------------------------------
  54. <table id="data-table-buttons" class="table table-striped table-bordered">
  55.     <thead>
  56.         <tr>
  57.             <!--<th width="1%" data-orderable="false"></th>-->
  58.             <th class="text-nowrap">Id</th>
  59.             <th class="text-nowrap">Data</th>
  60.             <th class="text-nowrap">Loja</th>
  61.             <th class="text-nowrap">Produto</th>
  62.             <th class="text-nowrap">Qtde</th>
  63.             <th class="text-nowrap">Vlr. Unit.</th>
  64.             <th class="text-nowrap">Vlr. Total</th>
  65.         </tr>
  66.     </thead>
  67. </table>
  68. -------------------------------------- Script DataTable --------------------------------------
  69.  
  70. <script type="text/javascript" language="javascript">
  71.     $(document).ready(function() {
  72.         $('#data-table-buttons').DataTable( {
  73.             dom: 'Bfrtip',
  74.             buttons: [
  75.                 'copy', 'csv', 'excel', 'pdf', 'print'
  76.             ],
  77.             "processing": true,
  78.             "serverSide": true,
  79.             "ajax": {
  80.                 "url": "busca.php",
  81.                 "type": "POST"
  82.             },
  83.             "columns" : [ {
  84.                 "data" : "Id"
  85.             }, {
  86.                 "data" : "data"
  87.             }, {
  88.                 "data" : "loja"
  89.             }, {
  90.                 "data" : "produto"
  91.             },{
  92.                 "data" : "qtde"
  93.             },{
  94.                 "data" : "vlrunitario"
  95.             },{
  96.                 "data" : "vlrtotal"
  97.             }]             
  98.         } );
  99.     } );
  100. </script>
  101.  
  102. -------------------------------------- PHP --------------------------------------
  103.  
  104. <?php
  105. include("../conexao/conexao.php");
  106.  
  107. $query = mysqli_query($conn, "select Id, data, loja, produto, qtde, vlrunitario, vlrtotal from vendas where loja=1 and data=20190102");
  108.  
  109. $result = array();
  110.  while ($rows = mysqli_fetch_assoc($query)) {
  111.         $id = $rows['Id'];
  112.         $data = $rows['data'];
  113.         $loja = $rows['loja'];
  114.         $produto = $rows['produto'];
  115.         $qtde = $rows['qtde'];
  116.         $vlrunitario = $rows['vlrunitario'];
  117.         $vlrtotal = $rows['vlrtotal'];
  118.  
  119.         $result[] = array($id,$data,$loja,$produto,$qtde,vlrunitario,$vlrtotal);
  120.     }
  121. }
  122. echo json_encode(array($result));
  123.  
  124. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement