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?

[php]

@page { size 8.5in 11in; margin: 2cm } div.page { page-break-after: always }
<?php echo "Page 1"; ?>
<?php echo "Page 2"; ?>
[/php]

I got:

Page 1 Page 204/04/14 on my screen

this was the heading printed on page one and only page one

Page 204/04/14

following is the placement of your code.

[code]

table, td, th { border:1px #CCFFFF; } th { background-color:#CCFFFF; color:black; } @page { size 8.5in 11in; margin: 2cm } div.page { page-break-after: always }
<?php error_reporting(0); mysql_connect('localhost','root',''); mysql_select_db('mydb') or die("Unable to select database"); $query=" SELECT * FROM mytbl WHERE payrec = 'R' AND pd = 'N' ORDER BY datepaid ASC"; $result=mysql_query($query); $num=mysql_numrows($result); // echo "Page 1"; ?>
<?php echo "Page 2"; echo date('m/d/y'); echo "
Report [/code]

Thats not the code I gave you. Try MY code by itself.

And why would you turn error reporting off when you are in development?

this does the same:
[php]<?php
echo “Page 1
”;
echo “Page 2”;
?>
[/php]

No, it does not do the same thing. Not even close.

I’m sorry Kevin, I don’t know why but when I ran your code all I got was the two lines:

Page 1
Page 2

Its not about running it so to speak, it is about the printing with page breaks which is what the jist of your request was. The headers on each page and numbering is simple once you see what it really does.

To see what it does go to print preview in your browser on the page you are running it from.

I see what you’re saying; I just need to figure out to apply it to my code.

For the headers, just create the header in a file and include it in each section. This code is for printing, not webpage display. If you do this with includes as I show below, you can create a different page for web display.

[php]

<?php include("/path/to/header.php") include("/path/to/page1Data.php") echo "Page 1"; ?>
<?php include("/path/to/header.php") include("/path/to/page2Data.php") echo "Page 2"; ?>
[/php]

Please bear with me; as I’ve said I’m really just a noobie. Am I correct in that
“include(”/path/to/header.php")" in my case might be “include(”/localhost/invoice/apheader.php")"

no, the path is the local path on the server. you need to either use the full path or the relative path from where you are

ie:

/home/ckir5951/www/invoice/apheader.php

or

invoice/apheader.php

One additional note, if you your working directory is levels down from localhost (root directory) you will need to add a period and forward slash like so:

[size=14pt]./[/size]invoice/apheader.php

Example :
localhost/mytestingdirectory/files_are_here

Without it, the server expects your files to be relative to the root directory at localhost.

Sponsor our Newsletter | Privacy Policy | Terms of Service