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
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:
@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; }
}
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.
@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; }
}
<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>