Hi,
I have a database table. If the table is empty i just want to display a simple message.
Here is my code.
<?php if (!empty($cis_data)) { ?>
<?php $total = 0; ?>
<?php foreach($cis_data as $deductions) { ?>
<?php $total += $deductions['deduction_amount']; ?>
<?php } ?>
<?php if (!empty($total)) { ?>
<input type='button' id='print-page' value='Print' onclick='window.print();'>
<div>
<p><?php echo htmlspecialchars($_SESSION['login']['customer_name']); ?></p>
<p><?php echo htmlspecialchars($_SESSION['login']['company_name']); ?></p>
<p class="total">2022 To 2023 : Total CIS Deductions<br> <b>£<?php echo $total; ?></b><br></p>
<table class="printable-table">
<tr>
<th>Deduction date</th>
<th>Deduction amount</th>
</tr>
<tbody>
<?php foreach($cis_data as $deductions) { ?>
<tr>
<?php $date_created = new DateTime($deductions['date_created']); ?>
<td><?php echo $date_created->format('d M Y'); ?></td>
<td><?php echo htmlspecialchars($deductions['deduction_amount']); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
<?php } ?>
</div>
</div>