我已经在使用商店收入的每日报告,但我需要我的报告来执行以下操作:我想查看特定日期范围或几周或几个月的收入报告....基本上我可以选择我想查看的日期或日期范围,以便打印我的选择。
这是inc.php
<?
$dbtype = "mysql";
$dbhost = "localhost";
$dbname = "anillos";
$dbuser = "rubi";
$dbpass = "----";
$conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
$conn->exec("set names utf8");
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
?>
这是我的代码:
<table class="table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Fecha</th>
<th>Total Anillos Vendidos</th>
<th>Total ganado del día</th>
</tr>
</thead>
<tbody id="result_fechas">
<tr>
<?
include 'inc.php';
$sql = $conn->prepare("SELECT DATE(start) AS date, COUNT(id_anillos) AS total_anillos, SUM(ventas) AS total_diario_ganado
FROM PRODUCTOS WHERE start >= CURDATE() AND start < CURDATE() + INTERVAL 1 DAY ORDER BY start ASC");
$sql->execute();
while($row = $sql->fetch(PDO::FETCH_ASSOC)) {
?>
<td class="center"><? echo $row['date']; ?></td>
<td class="center"><? echo $row['total_anillos']; ?></td>
<td class="center"><? echo $row['total_diario_ganado']; ?></td>
</tr> <? } ?>
</tbody>
你能帮我解决这个问题吗……我真的不知道……
- - 更新 - - -
@ Chris78 我做了这个表格:
<form name="fechas" id="fechas" method="post" >
<fieldset>
<legend>Reporte desde : </legend>
<input type="text" value="" placeholder="YYYY-MM-DD" name="f_desde" id="datepicker"/>
<legend>Reporte hasta : </legend>
<input type="text" value="" placeholder="YYYY-MM-DD" name="f_hasta" id="datepicker2" />
<button class="btn btn-inverse" type="submit" name="enviar" >
<i class="icon icon-print icon-white"></i>
Ver Reporte </button>
</fieldset>
</form>
新的选择代码:
<?
$sql = $conn->prepare("SELECT DATE(start) AS date, COUNT(id_anillos) AS total_anillos, SUM(ventas) AS total_ganado FROM PRODUCTOS WHERE start BETWEEN 'f_desde' AND 'f_hasta' ORDER BY start ASC");
$sql->execute();
while($row = $sql->fetch(PDO::FETCH_ASSOC)) {
?>
桌子 :
<table class="table-bordered table-striped table-condensed">
<thead>
<tr>
<th>rango de fechas seleccionado</th>
<th>Total Anillos Vendidos</th>
<th>Total ganado</th>
</tr>
</thead>
<tbody id="result_fechas">
<tr>
<?
////////SELECT CODE HERE
?>
<td class="center"><? echo $row['date']; ?></td>
<td class="center"><? echo $row['total_anillos']; ?></td>
<td class="center"><? echo $row['total_ganado']; ?></td>
</tr> <? } ?>
</tbody>
我尝试在同一页面中使用 ajax 调用显示结果
<script type="text/javascript">
$(function(){
$("#fechas").submit(function(){
$.ajax({
type:"POST",
url:".reportes.php?ts=" + new Date().getTime(),
dataType:"text",
data:$(this).serialize(),
beforeSend:function(){
$("#loading").show();
},
success:function(response){
$("#result_fechas").append(response);
$("#loading").hide();
}
})
return false;
});
});
});
</script>
reportes.php 是表单和等待结果的表格所在的同一页面....但我不知道错误在哪里,因为没有捕获 ajax 数据并且当我单击按钮时页面正在刷新...你能帮我解决这个问题吗?