Filtrar por data inicial e data final
Estou com dificuldade para filtrar um relatório por data inicial e data final.
Código:
<body>
<?php
include_once("menu_admin.php");
$resultado = mysql_query("SELECT * FROM vendas ORDER BY 'id'");
$linhas = mysql_num_rows($resultado);
?>
<div class="content-wrapper">
<!--<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4"> -->
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
<!--<h1 class="h2">Bem Vindo a Area Administrativa</h1> -->
<div class="btn-toolbar mb-2 mb-md-0">
<!-- <div class="btn-group mr-2">
<button class="btn btn-sm btn-outline-secondary">Share</button>
<button class="btn btn-sm btn-outline-secondary">Export</button>
</div> -->
<!-- <button class="btn btn-sm btn-outline-secondary dropdown-toggle">
<span data-feather="calendar"></span>
This week
</button> -->
</div>
</div>
<!--<canvas class="my-4" id="myChart" width="900" height="380"></canvas> -->
<br>
<h2 class="text-center">Relatório de Vendas</h2>
<div class="table-responsive">
Data Inicial <input id="datainicial" name="datainicial" type = 'date'>
Data Final <input id="datafinal" name="datafinal" type = 'date'>
<input type="submit" class="btn btn-success" value = "Buscar">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>ID</th>
<th>Nome Cliente</th>
<th>Nome Vendedor</th>
<th>Desc Produto</th>
<th>Data</th>
<th>Valor</th>
<th>Pagamento</th>
</tr>
</thead>
<tbody>
<?php
while($linhas = mysql_fetch_array(
$resultado)){
echo " <tr>";
echo "<td>".$linhas['id']."</td>";
echo "<td>".$linhas['descricao_cliente']."</td>";
echo "<td>".$linhas['descricao_vendedor']."</td>";
echo "<td>".$linhas['descricao_produto']."</td>";
$data = $linhas['creat'];
echo "<td>".date('d/m/Y', strtotime($data))."</td>";
echo "<td>".$linhas['valor_produto']."</td>";
echo "<td>".$linhas['tipo_pagamento']."</td>";
echo " </tr>";
}
?>
<div class="table-responsive">
<table class="table table-striped table-sm">
<?php
$resultado = mysql_query( "SELECT SUM(valor_produto) AS valor_total FROM vendas");
while($linhas = mysql_fetch_array($resultado)){
echo "<tr><td colspan='4'><b><div align='left'>Total de Venda:</td>";
echo "<td><b><div align='left'>".$linhas['valor_total']."</td>";
echo " </tr>";
?>
<?php
}
?>
</div>
</div>
</div>
</table>
</div>
</table>Discussão (1)
Carregando comentários...