1 回答
TA贡献1827条经验 获得超4个赞
您应该将两个查询合并为一个,然后根据例如ExpenseType
$ret=mysqli_query($con,"select *
from tblexpense
where (ExpenseDate BETWEEN '$fdate' and '$tdate')
and (ExpenseType='Expense' or ExpenseType='Income')
and UserId='$userid'
ORDER BY ExpenseDate ASC");
然后在您的循环中:
<tr>
<td><?php echo date('d/m/Y', strtotime($row["ExpenseDate"]));?></td>
<td><?php echo $row['ExpenseItem'];?></td>
<td><?php echo $row['ExpenseType'] = 'Expense' ? $row['ExpenseCat'] : '';?></td>
<td style="text-align:right;"><?php echo $row['ExpenseType'] = 'Expense' ? '' : number_format($row['ExpenseCost'], 2); ?> THB</td>
<td style="text-align:right;"><?php echo $row['ExpenseType'] = 'Expense' ? number_format($row['ExpenseCost'], 2) : '';?> THB</td>
<td style="text-align:right;"><?php echo number_format($row['ExpenseCost'], 2);?> THB</td>
</tr>
- 1 回答
- 0 关注
- 109 浏览
添加回答
举报