Filtrar por data
Tó com dificuldade para fazer um filtro que aconteça a medida que eu vou colocando as datas no input
Agradeço desde já vlw
<?php
include_once('conexao.php');
$sql = sprintf("SELECT * FROM caixa ORDER BY 'data' ");
$dados = mysqli_query($con,$sql) or die(mysqli_error());
$resul = mysqli_query($con, "SELECT sum(dinheiro) FROM caixa");
function between(){
if(!empty($data0) and empty($data1)){
$data0 = $_GET['data0'];
$data1 = $_GET['data1'];
$sql = mysqli_query("SELECT metodo,dinheiro,data FROM caixa WHERE data BETWEEN '$data0' and '$data1'");
$dados0 = mysqli_query($con,$sql) or die(mysqli_error());
while($linha = mysqli_fetch_array($dados0)) { ?>
<tr>
<td><?php echo $linha['metodo']?></td>
<td><?php echo "R$ ". $linha['dinheiro']?></td>
<td width="120"><?php echo date('d/m/Y', strtotime($linha['data']))?></td>
</tr>
<?php } ?>
<?php
}
}
?>
<!DOCTYPE html>
<html lang="PT-BR">
<head>
<title></title>
<!-- META-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
*{
margin:0px;
padding:0px;
}
table,th,td{
border:none
}
table{
width:100%;
display:table;
}
table th{
text-align:center!important;
}
table td{
text-align:left!important;
}
table.bordered>thead>tr,table.bordered>tbody>tr{
border-bottom:1px solid #d0d0d0;
}
table.striped>tbody>tr:nth-child(odd){
background-color:#f2f2f2;
}
table.striped>tbody>tr>td{
border-radius:0;
}table.highlight>tbody>tr{
transition:background-color .25s ease;
}
table.highlight>tbody>tr:hover{
background-color:#f2f2f2;
}
table.centered thead tr th,table.centered tbody tr td{
text-align:center;
}
.title{
text-align:center!important;
padding:15px 5px;
font-family:'times new roman';
font-size:20px;
}
thead{
border-bottom:1px solid #d0d0d0;
}
td,th{
padding:15px 5px;
display:table-cell;
}
.delete {
-moz-box-shadow: 0px 1px 0px 0px #fff6af;
-webkit-box-shadow: 0px 1px 0px 0px #fff6af;
box-shadow: 0px 1px 0px 0px #fff6af;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffec64), color-stop(1, #ffab23));
background:-moz-linear-gradient(top, #ffec64 5%, #ffab23 100%);
background:-webkit-linear-gradient(top, #ffec64 5%, #ffab23 100%);
background:-o-linear-gradient(top, #ffec64 5%, #ffab23 100%);
background:-ms-linear-gradient(top, #ffec64 5%, #ffab23 100%);
background:linear-gradient(to bottom, #ffec64 5%, #ffab23 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffec64', endColorstr='#ffab23',GradientType=0);
background-color:#ffec64;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #ffaa22;
display:inline-block;
cursor:pointer;
color:#333333;
font-family:Arial;
font-size:12px;
font-weight:bold;
padding:6px 15px;
text-decoration:none;
text-shadow:0px 1px 0px #ffee66;
}
.delete:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ffab23), color-stop(1, #ffec64));
background:-moz-linear-gradient(top, #ffab23 5%, #ffec64 100%);
background:-webkit-linear-gradient(top, #ffab23 5%, #ffec64 100%);
background:-o-linear-gradient(top, #ffab23 5%, #ffec64 100%);
background:-ms-linear-gradient(top, #ffab23 5%, #ffec64 100%);
background:linear-gradient(to bottom, #ffab23 5%, #ffec64 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffab23', endColorstr='#ffec64',GradientType=0);
background-color:#ffab23;
}
.delete:active {
position:relative;
top:1px;
}
@media screen and (max-width: 750px){
footer{
position:absolute;
top:1200px;
}
}
</style>
</head>
<body>
<table class="bordered striped highlight">
<p class="title">Caixa da Igreja</p>
<p>Pesquise por Data :    <input type="date" name="data0" required>  Até   <input type="date" name="data1" required>
<?php while($linha = mysqli_fetch_array($dados)) { ?>
<tr>
<td><?php echo $linha['metodo']?></td>
<td><?php echo "R$ ". $linha['dinheiro']?></td>
<td width="120"><?php echo date('d/m/Y', strtotime($linha['data']))?></td>
</tr>
<?php } ?>
</br>
</table></p>
<div id="total">
<?php while($result = mysqli_fetch_array($resul)){
echo "Total R$: ".$result['sum(dinheiro)'].'<br/>';
}?>
</div>
</br>
</body>
</html>Discussão (2)
Carregando comentários...