Click here to Skip to main content
15,885,875 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I am working in a project using Codeigniter / mysql and I want a table showing Fee details for multiple sessions, what I want is to show session for each group once and also to show a subtotal of that session at the end, I successfully did to show/display the session as group row in table but not able to display the subtotal row.

Image of the table is attached:

Students-Fee-Detail

Please help.

What I have tried:

PHP
<table class="table table-striped table-bordered table-sm">
                <thead>
                <tr>
                    <th>FeeType</th>
                    <th>FeePayable</th>
                    <th>PaidAmount</th>
                    <th>Balance</th>
                    <th>PaidDate</th>
                    <th>Paid</th>
                </tr>
                </thead>
                <tbody>
                <?php $feedails = getFeeDetail($row['studentid']);
                $sessionid = null;
                foreach($feedails as $obj){
                    if($obj['sessionid'] != $sessionid || $sessionid == null){
                         ?>
                    <tr class="bg-dark text-white">
                        <td colspan="6"><?=$obj['session']; ?></td>
                    </tr>
                    <tr>
                    <td><?=$obj['feetype'];?></td>
                    <td><?=$obj['feepayable'];?></td>
                    <td><?=$obj['paidamount'];?></td>
                    <td><?=$obj['balance'];?></td>
                    <td><?=$obj['paiddate'];?></td>
                    <td><?php if($obj['paid'] == 1 || $obj['paid'] == 2) { ?> Fee Paid <?php }
                    else { ?> Not Paid <?php } ?></td>
                </tr>
                    <?php $sessionid = $obj['sessionid'];
                 } else { ?>
                <tr>
                <td><?=$obj['feetype'];?></td>
                <td><?=$obj['feepayable'];?></td>
                <td><?=$obj['paidamount'];?></td>
                <td><?=$obj['balance'];?></td>
                <td><?=$obj['paiddate'];?></td>
                <td><?php if($obj['paid'] == 1 || $obj['paid'] == 2) { ?> Fee Paid <?php }
                    else { ?> Not Paid <?php } ?></td>
                </tr>
              <?php 
                    }
                }
                ?>
                </tbody>
            </table>
Posted
Updated 23-Sep-22 20:49pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900