12 replies [Last post]
TheStalker
Offline
newbie
Last seen: 14 years 23 weeks ago
Joined: 2008-12-17
Posts: 6
Points: 0

ok,
i have a php dcument that has a number of tables in. I want to be able to choose where the page break will be within the tables. e.g. i only want 3 tables per sheet of paper then the next 3 tables and so on. Is there an easy way to do this with css?

many thanks

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 8 years 20 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

It's called 'paged

It's called 'paged media'

Have a read through the specs to familiarize yourself with these properties. In use check thoroughly cross browser.

http://www.w3.org/TR/CSS21/page.html

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Triumph (not verified)
Anonymous's picture
Guru

Guess which browser is going

Guess which browser is going to give you the most trouble.

TheStalker
Offline
newbie
Last seen: 14 years 23 weeks ago
Joined: 2008-12-17
Posts: 6
Points: 0

IE?

IE?

Triumph (not verified)
Anonymous's picture
Guru

TheStalker wrote:IE? You

TheStalker wrote:

IE?

You win! Or do we all lose? I forget.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 8 years 20 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

It isn't going to give me

It isn't going to give me any problem :shrug: IE dosen't support them, tough; can't do much about that, still going to ensure that at least some browsers have a chance Smile

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

TheStalker
Offline
newbie
Last seen: 14 years 23 weeks ago
Joined: 2008-12-17
Posts: 6
Points: 0

kind of got it working using

kind of got it working using this

table{
page-break-after:always
}

but IE prints an extra page at the end. Also Really wanted it to work using the

div{
page-break-after:always
}

but it dosnt work at all Sad

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 8 years 20 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

PDF is the way to go,

PDF is the way to go, browser printing is largely a waste of time if you need any sort of real layout control.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

TheStalker
Offline
newbie
Last seen: 14 years 23 weeks ago
Joined: 2008-12-17
Posts: 6
Points: 0

im starting to think the

im starting to think the same thing. Although its wired why it works with the table and not with div as i want 3 tables then the next 3 table etc etc.... :?

TheStalker
Offline
newbie
Last seen: 14 years 23 weeks ago
Joined: 2008-12-17
Posts: 6
Points: 0

ok this now

ok this now works

div{
page-break-after : always;
}
 
<div>
{code here}
</div>

IE still prints an extra page off, where firefox does'nt. Is this IE just being IE or is there a way i can fix it ??

mosherjm
Offline
newbie
Virginia
Last seen: 14 years 23 weeks ago
Virginia
Timezone: GMT-5
Joined: 2008-12-17
Posts: 6
Points: 0

RE: ok this now

try using page-break-before:always; instead and put the div in the beginning of your loop.

NOTE: i'm not PHP expert, but something like this

for ( $counter = 0; $counter <= upperbound; $counter += 1) {
if ( $counter % 3 == 0 ) {
	echo "<div style='page-break-before:always'></div>";
}
	echo "<table><tr><td>";
	echo $counter;
	echo "</td></tr></table>";
}

TheStalker
Offline
newbie
Last seen: 14 years 23 weeks ago
Joined: 2008-12-17
Posts: 6
Points: 0

this just gives me a blank

this just gives me a blank page at the begining Shock

mosherjm
Offline
newbie
Virginia
Last seen: 14 years 23 weeks ago
Virginia
Timezone: GMT-5
Joined: 2008-12-17
Posts: 6
Points: 0

how about this....

how about this....

for ( $counter = 0; $counter <= upperbound; $counter += 1) {
if ( ($counter % 3 == <img src="https://csscreator.com/sites/all/modules/smileys/packs/Roving/innocent.png" title="Innocent" alt="Innocent" class="smiley-content" /> && ($counter > <img src="https://csscreator.com/sites/all/modules/smileys/packs/Roving/innocent.png" title="Innocent" alt="Innocent" class="smiley-content" /> ) {
	echo "<div style='page-break-before:always'></div>";
}
	echo "<table><tr><td>";
	echo $counter;
	echo "</td></tr></table>";
}