0

Below is my code for display data on print preview..

In this table i need to repeat header on every page.

I need to print only 10 rows in each page..After that need page break and display Data data on next page With repeating header...

Now my prob. is my code repeat header after 10 rows but i cannot understand how to break page after 10 rows and header display on next page...not in middle of the page...

plz help me..

<td width="38%"><input type="submit" value="print" onClick="PrintDiv();" /></td>


<table border="1px solid #666" cellpadding='0' cellspacing='0'>
        <thead>
        <tr>
            <th width="4%">Sr.No</th>
            <th width="10%">Book / Recpt No</th>             
             <th width="7%">Booking Dt</th>
             <th width="9%">Copy Start Dt</th>
             <th width="14%">Surveyor Name</th>
            <th width="18%">Customer</th>                           
            <th width="27%">Coupon No</th>          
            <th width="5%">Price</th>
            <th width="6%">Gift Del.</th>
        </tr>
        </thead>
       <?php
        $i=1;  
        $counter=1; 
        $pageCounter=1;
        foreach($data as $row){     
        ?>
        <?php
        if($counter==11)
        {       
        $counter=1; 
        ?>          
        <thead>
        <tr class="breakAfter">
            <th width="4%">Sr.No</th>
            <th width="10%">Book / Recpt No</th>             
             <th width="7%">Booking Dt</th>
             <th width="9%">Copy Start Dt</th>
             <th width="14%">Surveyor Name</th>
            <th width="18%">Customer</th>                           
            <th width="27%">Coupon No</th>          
            <th width="5%">Price</th>
            <th width="6%">Gift Del.</th>
        </tr>
        </thead>
        <?php } ?>
         <tbody>        
            <tr>
            <td height="54"><?php echo $i; ?></td>
            <td><?php echo htmlspecialchars($row['book_no']); ?> / <?php echo htmlspecialchars($row['receipt_no']); ?></td>         
            <td><?php echo htmlspecialchars($row['bookingdate']); ?></td>   
            <td><?php echo htmlspecialchars($row['startingdate']); ?></td>  
            <td><?php echo htmlspecialchars($row['surveyor_name']); ?></td>
            <td><?php echo htmlspecialchars($row['prefix']); ?>,<?php echo htmlspecialchars($row['customer_name']); ?></td>         
            <td><?php echo htmlspecialchars($row['cou']); ?></td>
            <td><?php echo htmlspecialchars($row['amount']); ?></td>
            <td><?php echo htmlspecialchars($row['deliveredgift']); ?></td>
        </tr>
        <?php $counter++; $i++;  }?>
        </tbody>

    </table>
varsha bajpai
  • 65
  • 2
  • 9
  • What do you mean with "on the next page"? Do you mean with pagination? – redelschaap Mar 21 '15 at 13:10
  • Are you using CSS to "page-break"? If so, are you looking at the Print Preview for your end result? – bloodyKnuckles Mar 21 '15 at 13:11
  • possible duplicate of [How to deal with page breaks when printing a large HTML table](http://stackoverflow.com/questions/1763639/how-to-deal-with-page-breaks-when-printing-a-large-html-table) – Sinan Ünür Mar 21 '15 at 13:36
  • i dont need pagination..........i need to repeat header on every page...and the main thing is header display always top on each page...my code display header on midlle of pages like wise.... – varsha bajpai Mar 21 '15 at 13:39
  • i tried using css but not working in my code.... – varsha bajpai Mar 21 '15 at 13:39
  • Well do you mean within print previews? Then you should work with page breaks as suggested before. You should try that and if that's not working out, adjust you question with what you've already tried. – redelschaap Mar 21 '15 at 13:45
  • i tried above solution but not repeat header and if i try with my code this cut a header in half, making it unreadable. – varsha bajpai Mar 21 '15 at 14:06

0 Answers0