I would like if its possible to show the sum of the records get it from database but from only per page.
So i insert all values into database and show it at the mpdf page and at the last page i show the total from all values into database but i would like to show per page the sum of the records only showed per page. I guess its kinda impossible, i seriously dont know how to do it. Any help would be appreciated.
Page1: value1 value2 total_page1
Page2: value1 value2 value3 total_page2
PS: The values are from database.
Cumps.
To accomplish something like that in SQL, you need to use aggregation. For example, a count of results per page might look something like this:
SELECT page_number, COUNT(*) AS numResults
FROM myTable
GROUP BY page_number;
Use {colsum}. It will automatically add sum on every page in the table. It's on http://mpdf1.com/examples/mpdf54demo.pdf.
You can read the code in example file included in downloaded library examples/example58_new_mPDF_v5-4_features.php
<table>
<thead>
<tr>
<th>Header Row</th>
<th>Header Row</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Column total: (using colsum2 in {})</td>
<td>{colsum2}</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Row 1</td>
<td>167.00</td>
</tr>
<tr>
<td>Row 2</td>
<td>444.53</td>
</tr>
<tr>
<td>Row 3</td>
<td>14.00</td>
</tr>
<tr>
<td>Row 4</td>
<td>0.88</td>
</tr>
<tr>
<td>Row 5</td>
<td>144.00</td>
</tr>
<tr>
<td>Row 6</td>
<td>8089.00</td>
</tr>
<tr>
<td>Row 7</td>
<td>3.00</td>
</tr>
<tr>
<td>Row 8</td>
<td>23.00</td>
</tr>
</tbody>
</table>
NOTE: Make sure to place <tfoot>
before <tbody>
.