Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Precisa de ajuda para criar um livro-razão simples a partir de tabelas de dívida e crédito do mysql?


para imprimir a tabela pode ser algo semelhante a seguir usando o array preparado como array final
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Document</title>
</head>
<body>
    <h1>Customer Ledger(<?php echo $rearrangedFinalData[0]['customer'] ?>)</h1>
    <table>
        <tr>
            <td>Date</td>
            <td>Invoice No</td>
            <td>Debit</td>
            <td>Credit</td>
            <td>Balance</td>
        </tr>
        <?php 
        //initialize balance as per your requirement
        $balance = 0;
        foreach($rearrangedFinalData AS $row) {
         ?>
        <tr>
            <td><?php echo $row['date'] ?></td>
            <td><?php echo $row['invoice'] ?></td>
            <td><?php echo $row['debit'] > 0 ? $row['debit'] : '' ?></td>
            <td><?php echo $row['credit'] > 0 ? $row['credit'] : '' ?></td>
            <td><?php echo $balance = ($balance + $row['debit'] - $row['credit']) ?></td>
        </tr>
        <?php } ?>
    </table>
</body>
</html>