this image is showing 2 tables and output UI
我的代码如下
//********************** credit query ***************************/
$sql = 'SELECT *,sum(pl_amount) as sum_pl_amount FROM payments_log left join payments on payments_log.pl_order_no=payments.order_no WHERE pl_date LIKE "%'.$date.'%" group by pl_date order by pl_id';
$qry = mysqli_query($connection,$sql);
while($cData = mysqli_fetch_assoc($qry))
{
$creditData[] = $cData;
}
//********************** debit query ***************************/
$query = "SELECT *, sum(e_amount) as sum_e_amount FROM expenses WHERE e_date LIKE '%".$date."%' group by e_date order by e_date";
$run = mysqli_query($connection,$query);
$cnt = mysqli_num_rows($run);
while($dData = mysqli_fetch_assoc($run))
{
$debitData[] = $dData;
}
//echo '<pre>';print_r($creditData);print_r($debitData);
//******************** print data ***************************/
for($j=0;$j<$cnt;$j++)
{
$dateStr = '';
$creditAmt = '';
$debitAmt = '';
if(array_key_exists($j, $creditData) && array_key_exists($j, $debitData))
{
if($creditData[$j]['pl_date'] === $debitData[$j]['e_date'])
{
$dateStr = changeDateFormat('Y-m-d','d/m/Y',$creditData[$j]['pl_date']);
$creditAmt = $creditData[$j]['sum_pl_amount'];
$debitAmt = $debitData[$j]['sum_e_amount'];
}
if(array_key_exists($j, $creditData))
{
$dateStr = changeDateFormat('Y-m-d','d/m/Y',$creditData[$j]['pl_date']);
$creditAmt = $creditData[$j]['sum_pl_amount'];
$debitAmt = '';
}
if(array_key_exists($j, $debitData))
{
$dateStr = changeDateFormat('Y-m-d','d/m/Y',$debitData[$j]['e_date']);
$creditAmt = '';
$debitAmt = $debitData[$j]['sum_e_amount'];
}
}
?>
<tr role="row">
<td> <?php echo $i;?></td>
<td> <?php echo $dateStr; ?></td>
<td> <?php echo $creditAmt;?></td>
<td> <?php echo $debitAmt; ?></td>
</tr>
<?php $i++;
}?>
我正在尝试打印日期明智的月度资产负债表,这将显示信用和借记金额,如上图
任何人都可以检查我的代码并帮助我获得所需的输出。
先谢谢