SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    at a loss re. page break and page numbering

    need suggestions pertaining to the above title. I want to print my php report w/heading at the top
    of each page with page numbering. Anyone

  2. #2
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,805
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    this is really difficult to answer w/o seeing RELEVANT code and knowing more details about your actual strategy for page numbering.

    Off the top of my head , however, I would guess that you could find the rule for your page break, do an @media print ( media query) with a counter, and finally output the value of the counter in a :before pseudo element. Something ROUGHLY like this:

    Code:
    @media all {
    	.page-break	{ display: none;  }
            body {counter-reset: section; }
         .page-break:before { counter-increment: section; diplay:block;  content: "Page " counter(section); }
    
    @media print {
    	.page-break	{ display: block; page-break-before: always; }
    }

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your response, I'm trying to learn. In my research and from forums, the solution is from 3 lines of code to nearly 100, javascript to pdf, no result to a page of errors. Following is your offering followed by code: I'm not sure
    the placement.
    Code:
    @media all {
     
    	.page-break	{ display: none;  }
     
            body {counter-reset: section; }
     
         .page-break:before { counter-increment: section; diplay:block;  content: "Page " counter(section); }
     
     
     
    @media print {
     
    	.page-break	{ display: block; page-break-before: always; }
     
    }
    -------------------------------------------------------------
    Code:
    <html><body><center>
     <?php 
    error_reporting(E_ALL ^ E_NOTICE);
    // error_reporting(0);
    mysql_connect('localhost','root','');
    mysql_select_db('homedb') or die("Unable to select database");
    $query=" SELECT * FROM mytbl WHERE payrec = 'P' AND pd = 'N' ORDER BY datepaid ASC";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    //  
    echo date('m/d/y');
    echo "<font size=+1><b><center> Accounts Payable Report</font></center></b></b><br />";
    ?>
    <table cellspacing=0 cellpadding=0 border=1>
    <thead>
    <tr>      
    <th colspan=4></th>
    <th bgcolor="#ccffff">date</th>
    <th bgcolor="#ccffff">days</th>
    <th bgcolor="#ccffff">amt</th>
    <tr>
    <th bgcolor="#ccffff">recur?</th>
    <th bgcolor="#ccffff">acct#</th>
    <th bgcolor="#ccffff">creditor</th>
    <th bgcolor="#ccffff">purpose</th>
    <th bgcolor="#ccffff">due</th>
    <th bgcolor="#ccffff">late</th>
    <th bgcolor="#ccffff">due</th>
    </tr>
    <?php
    while($row = mysql_fetch_array($result))
       {
    $totdue += $row['amtdue'];   
              echo '
                <tr>
                    <td>', $row['status'], '</td>
                    <td>', $row['acctno'], '</td>
                    <td>', $row['bname'], '</td>
                    <td>', $row['purpose'], '</td>
                    <td>', $row['duedate'], '</td>                
         <td align=right class="currency">', ($late > 120 ? 'pastdue' : $row['dayslate']), '</td>
         <td align=right class="currency">', number_format($row['amtdue'], 2, '.', ''), '</td>
       </tr>';
        }     
        echo '
          <tr>
            <th bgcolor="#ccffff" scope="row" colspan="6">Grand Total:</th>
              <td bgcolor="#FFD4D4" class="currency">', number_format($totdue, 2, '.', ''), '</td>
                </tr>
                 </table>';
                mysql_close();
               ?> 
    </body></html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •