close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Print style for repeating regions

Thread began 3/23/2009 3:07 pm by troyd | Last modified 3/28/2009 9:23 pm by troyd | 9377 views | 8 replies

troyd

That did it! Thanks a lot.:D
It took me about 6 hours today to get through all the mistakes I was making. Kept putting the 3 parts of your code in the wrong place. I read lots of stuff online about alternating row colors and that helped a little. There are lots of ways to do the same thing I think.

It took me forever to finally realize I had to echo the div.
I have your code here in use and it is giving me a desired page break every 2 records.

I will paste my practice code here for any critique. Please let me know if you see anything out of place or unnecessary. Such as the use of } else { .

It was working either way.

using

if( ($rowCounter % 2) == 0 ){
// write out page break div
echo '<div style="page-break-after:always"></div>';
} else {
echo '<div style="page-break-after:avoid"></div>';
}

or just

if( ($rowCounter % 2) == 0 ){
// write out page break div
echo '<div style="page-break-after:always"></div>';
}

but I figured it wouldn't hurt to use the "page-break-after:avoid" too.

One area that puzzles me is that even without using a @media print in the style, it still gives the page break only when printed. (Which is what I want). But just for future reference, I tried to also give it a background color every other row and that didn't work. It ignored my color but the page break still works. And I guess you can't use a media type in an inline style?

Here is my test code. It repeats all my records and when printed, it gives me a dynamically generated page break after every 2 records.

<?php
$rowCounter = 1;
?>
<?php do { ?>
<div><?php echo $row_Recordset1['id']; ?></div>
<?php
if( ($rowCounter % 2) == 0 ){

echo '<div style="page-break-after:always"></div>';
} else {
echo '<div style="page-break-after:avoid"></div>';
}
$rowCounter++;

?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<?php
mysql_free_result($Recordset1);
?>

Now to put into my working pages... :o

TroyD

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...