我有一个小脚本,我正在处理它,我可以在一个漂亮的表格中生成收入和支出报告,但是,我目前面临着排序顺序的一些问题。这是我当前的代码:
<div class="panel-body">
<div class="col-md-12">
<?php
$fdate=$_POST['fromdate'];
$tdate=$_POST['todate'];
$rtype=$_POST['requesttype'];
?>
<?php
$source1 = $_POST['fromdate'];
$date1 = new DateTime($source1);
$source2 = $_POST['todate'];
$date2 = new DateTime($source2);
?>
<h5 align="center" style="color:#30a5ff">Expense Report from <?php echo $date1->format('d/m/Y')?> to <?php echo $date2->format('d/m/Y')?></h5>
<hr />
<!-- table start--->
<table class="table table-bordered mg-b-0">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th>Category</th>
<th style="text-align:right;">Cash In</th>
<th style="text-align:right;">Cash Out</th>
<th style="text-align:right;background: yellow;">Balance THB</th>
</tr>
</thead>
<?php
$total_e = 0;
$userid=$_SESSION['detsuid'];
$ret=mysqli_query($con,"select * from tblexpense where (ExpenseDate BETWEEN '$fdate' and '$tdate') && (ExpenseType='Expense') && UserId='$userid' ORDER BY ExpenseDate ASC");
$cnt=1;
while ($row=mysqli_fetch_array($ret)) {
$total_e = $total_e+$row['ExpenseCost']
以下是输出的屏幕截图:
基本上输出和值是正确的,但是,我用红色标记的2个项目(即“提现”)没有按日期排序,因为我的其他费用值,而是添加到顶部。我的理想目标是让它们都按费用日期无缝排序。实现这一目标的最佳方式是什么?一些专家的帮助将不胜感激。
GCT1015