I have an accounting statement and want to fetch the expense and receive payment values, Using an While loop to display each one below each other.
I managed to do it but as separate table rows, one for expenses and the other for receive payment.
The variable $value is the customers name. It loops each table until all the given values are displayed, i want to combine the code so that it displays each expense and payment underneath each other and not separate... As following but im getting duplicate values
<?php //***************** Expenses ************
require '../Database/conn.php';
$query = mysqli_query($conn, "SELECT * FROM expenses WHERE payee LIKE '$value' ");
while($fetch = mysqli_fetch_array($query)) {
$expTot = substr($fetch['total'], 0, 100);
?>
<div style="word-wrap:break-word;">
<tr>
<td class="date">
<h6 class="mb-0 text-sm date"><?php echo substr($fetch['date'], 0, 100);?></h6>
</td>
<td class="date">
<h6 class="mb-0 text-sm date"><?php ?></h6>
</td>
<td class="type">
<h6 class="mb-0 text-sm type"><?php echo substr($fetch['type'], 0, 100);?></h6>
</td>
<td class="total">
<h6 class="mb-0 text-sm total"><?php echo "R-". substr($fetch['total'], 0, 100);?></h6>
</td>
<?php } ?>
</tr>
</div>
And the same for income.
<?php //************ recive payment ************
require '../Database/conn.php';
$query2 = mysqli_query($conn, "SELECT * FROM `recive_payment` WHERE `customer` LIKE '$value' ");
while($fetch2 = mysqli_fetch_array($query2)) {
?>
<div style="word-wrap:break-word;">
<tr>
<td class="date">
<h6 class="mb-0 text-sm customer"><?php echo substr($fetch2['date'], 0, 100);?></h6>
</td>
<td class="date">
<h6 class="mb-0 text-sm date"><?php ?></h6>
</td>
<td class="total">
<h6 class="mb-0 text-sm type"><?php echo substr($fetch2['type'], 0, 100);?></h6>
</td>
<td class="total">
<h6 class="mb-0 text-sm total"><?php echo "R". substr($fetch2['total'], 0, 100);?></h6>
</td>
<?php // search close
}
}
?>
</tr>
</div>