Click here to Skip to main content
15,885,763 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I want a Table within a Table with 3 columns in each row, to print 3 copies of each row from database table.
Example

I tried this code but it gives me error.Allowed memory size of 536870912 bytes exhausted

Thanks in advance.

What I have tried:

HTML
<table class="table table-sm">
        <table>
          <?php foreach($results as $row){ ?>
          <tr>
              <td>
                  <tr><th colspan="2"><?php echo $row->institutionname; ?></th></tr>
                    <tr><td colspan="2"><?php echo $row->sessionname.' '.$row->classname; ?></td></tr>
                    <tr><td><?php echo $row->admissionno.' '. $row->studentname; ?></td></tr>
                    <tr><td>Fee Type</td><td><?php echo $row->feetype; ?></td></tr>
                    <tr><td>Fee Month</td><td><?php echo $row->formonth; ?></td></tr>
                    <?php 
                    $tb = floatval($row->balance) - floatval($row->payableamount);
                    ?>
                    <tr><td>Remaining Dues</td><td><?php echo $tb; ?></td></tr>
                    <tr><td>Current Payable</td><td><?php echo $row->payableamount; ?></td></tr>
                    <tr><td>Total Payable</td><td><?php echo $row->balance; ?></td></tr>
                    <tr><td>Paid</td><td><?php echo ($row->paid==1)?'Yes':'No'; ?></td></tr>
              </td>
              <td>
                  <tr><th colspan="2"><?php echo $row->institutionname; ?></th></tr>
                    <tr><td colspan="2"><?php echo $row->sessionname.' '.$row->classname; ?></td></tr>
                    <tr><td><?php echo $row->admissionno.' '. $row->studentname; ?></td></tr>
                    <tr><td>Fee Type</td><td><?php echo $row->feetype; ?></td></tr>
                    <tr><td>Fee Month</td><td><?php echo $row->formonth; ?></td></tr>
                    <?php 
                    $tb = floatval($row->balance) - floatval($row->payableamount);
                    ?>
                    <tr><td>Remaining Dues</td><td><?php echo $tb; ?></td></tr>
                    <tr><td>Current Payable</td><td><?php echo $row->payableamount; ?></td></tr>
                    <tr><td>Total Payable</td><td><?php echo $row->balance; ?></td></tr>
                    <tr><td>Paid</td><td><?php echo ($row->paid==1)?'Yes':'No'; ?></td></tr>
              </td>
              <td>
                  <tr><th colspan="2"><?php echo $row->institutionname; ?></th></tr>
                    <tr><td colspan="2"><?php echo $row->sessionname.' '.$row->classname; ?></td></tr>
                    <tr><td><?php echo $row->admissionno.' '. $row->studentname; ?></td></tr>
                    <tr><td>Fee Type</td><td><?php echo $row->feetype; ?></td></tr>
                    <tr><td>Fee Month</td><td><?php echo $row->formonth; ?></td></tr>
                    <?php 
                    $tb = floatval($row->balance) - floatval($row->payableamount);
                    ?>
                    <tr><td>Remaining Dues</td><td><?php echo $tb; ?></td></tr>
                    <tr><td>Current Payable</td><td><?php echo $row->payableamount; ?></td></tr>
                    <tr><td>Total Payable</td><td><?php echo $row->balance; ?></td></tr>
                    <tr><td>Paid</td><td><?php echo ($row->paid==1)?'Yes':'No'; ?></td></tr>
              </td>
           </tr> 
            <?php } ?>
        </table>
    </table>
Posted
Updated 19-Jan-21 5:31am

1 solution

Understand the reason for this error & fix it. Check these
Fixing PHP Fatal Error: Allowed Memory Size Exhausted[^]
Fixing PHP Fatal error: Allowed memory size of (X) bytes exhausted.[^]

You must optimize your code, SQL query, web page & etc., which's the proper way.

EDIT

I found one issue in your HTML.

You put tr tag inside td tag. It's not a valid child element. It won't work. You need to use Nested Table. Check below page for example.
How to an Html Table inside another Table[^]
 
Share this answer
 
v2
Comments
nyt1972 19-Jan-21 11:38am    
thanks for the reply but I think I am getting this error bcoz of wrong use of table rows and columns, but I dont have idea that how to fix.
thatraja 19-Jan-21 11:52am    
First try to generate output with minimal nodes(Say 3-4 nodes). Ensure it generates output. Then add other nodes one by one. That way you can spot the issue.
Don't use SELECT *; Use SELECT Column Names in SQL query.
thatraja 19-Jan-21 11:57am    
Check my updated answer. That's the problem. I missed it first
nyt1972 19-Jan-21 12:09pm    
thanks
nyt1972 19-Jan-21 12:05pm    
tried that but still getting the error.

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