report by date

0

I need help with putting together a report that has a search by date. Today, this report brings all DB data to the database, so I need it to be for selected dates.

SQL can do it, the problem is even the report where the user places the date to search and it shows only information regarding the date entered.

My page looks like this:

    <?php
session_start();
$nivel = 1;
set_time_limit(0);
date_default_timezone_set('America/Sao_Paulo');
include 'adm/config.php';
include 'adm/functions.php';
include 'adm/menu.php';
include("adm/seguro.php");
?>

<table cellpadding="5" cellspacing="0" width="900" align="center">
<tr>
<td align="right">
<hr size="1" />
<h2><p align="center"><font color="#008000">Consulta ABC</font></p></h2>
</td>
</tr>
</table>
</body>
</html>
<head>
    <?php
         include "js/jquery.dataTables.php";?>
        <script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    $('#example').dataTable( {
        "bPaginate": false,
        "bLengthChange": false,
        "bFilter": true,
        "bSort": false,
        "bInfo": false,
        "bAutoWidth": false } );
} );
        </script>
         <link href="css/demo_table.css" rel="stylesheet" type="text/css">
      </head>
<?php
      $sel = mysqli_query ($conexao,"
SELECT DISTINCT d.cat_id prod, p.id, p.nome id_prod, SUM( d.qtd ) AS qtd_prod, SUM( d.valor_total ) AS total_prod FROM lc_controle c INNER JOIN lc_detalhe d ON d.controle_id = c.id INNER JOIN 'lc_cat' p ON p.id = d.cat_id WHERE d.tipo = '0' and c.dtConcat BETWEEN '2018-03-20' AND '2018-03-29' GROUP BY d.cat_id ORDER BY qtd_prod DESC
");

      $c = 1;

?>
 <table width="100%" border="1" cellpadding="1" cellspacing="0" class="display" id="example" align="center">
            <thead>
        <tr class="fonte_titulos">
   <th  bgcolor="#F4EADC">Produto</th>
   <th  bgcolor="#F4EADC">Quantidade</th>
   <th  bgcolor="#F4EADC">Valor Total</th>

    </thead>
    <tbody>
    <?php
        while ($dados = mysqli_fetch_array($sel))
        {
if (($c % 2) == 1){ $fundo="#F1F1F1"; }else{ $fundo="#E0E0E0"; }
        $id_prod = $dados["id_prod"];
        $qtd_prod = $dados ["qtd_prod"];
        $total_prod = $dados ["total_prod"];
        echo "<tr bgcolor =\"$fundo\" class=\"fonte_desc\"><td align=\"center\" width=\"590\">
$id_prod</td><td align='center'>$qtd_prod"."</td><td align='center'>$total_prod
        ";
    $c++;   }
        ?>
</table>
          </div>
   <p align="center"> </p>
 <?php include "rodape.php"; // fim?>

   </p>
    </body>
</html>
    
asked by anonymous 30.03.2018 / 00:15

0 answers