Skip to content Skip to sidebar Skip to footer

Php Code To Break Page After 6th Row

I try to display 2 table side by side with php code.... but i need to display only 6 table on single page ......and rest on another page...... so plz can any one help me to break p

Solution 1:

Try using CSS:

<style>@media print {
    .pageBreak {
        page-break-after: always;
    }
}
</style>

And at every 6 table, add a pageBreak:

<?php$lineCounter = 0;
if (is_array($data)) {
    foreach($dataas$row) {
        $lineCounter++;
?><!-- output a table... --><?phpif($lineCounter % 6 == 0) {
            echo'<span class="pageBreak"></span>' . PHP_EOL;
        }
    }
}
?>

Solution 2:

try this is code or visit link

<?php$q = "SELECT * FROM your_table ";
    $myq = mysqli_query($link, $q);
    $fixtures ='';
    $i=0;
        while($row=mysqli_fetch_assoc($myq)) {
            $r[]=$row;
        }

        foreach ($ras$val) {
            $i++;
    ?><!-- your value from database --><table><tr><td><?phpecho$val['your_column']; ?></td></tr></table><!-- your value from database --><?phpif($i % 6==0){
                echo'<div style="page-break-after: always;">[------ break ------]</div>' . PHP_EOL;
            $i=0;
            }
        }

    ?>

Post a Comment for "Php Code To Break Page After 6th Row"