Ng Hwee Hwee wrote:
is there a way to count how many lines of screen output has HTML render?
below is a sample of what i'm trying to do.. i'm trying to generate a table
with the Remarks column containing data type TEXT which may have a few
lines. therefore, i cannot just count how many rows of records i have. can
someone please help me??

basically, i need to insert a page break at every 20 lines of screen output
for printing purposes. can someone enlighten me on how i can read HTML
rendered output?? thank you really really soooo much!!!

I'm going to go out on a limb and answer your problem instead of your question - because I don't personally see your proposed method as a good solution for the problem. Put simply, it's impractical to try to approximate how the end users browser will render content, and no matter what you do, you'll constantly be tweaking for exceptions. Instead, we'll attack with the best weapon we have, HTML and CSS.

There are a number of ways you can get what you want, but you'll likely have to play with all of them just to get a single working solution.

1) thead/tfoot
This is likely the best bet and simplest way to get what you want - I assume the reason you are wanting to break the content up is because

2) CSS pagebreak options
'page-break-before' and 'page-break-after' can be set to 'always', 'auto', 'left', and 'right' - left and right are for printing on both sides - and afaik 'left' isn't supported by anyone, and 'right' has very limited support - still, as far as pagebreaks, you'll mostly be just forcing them with an always. It's worth noting that this is CSS2 - but it is some of the rare CSS2 that is supported in browsers [though not necessarily all, since there are even CSS1 properties not (properly) supported by all major browsers]

3) PRE tags if all else fails
If you can't get any of these solutions to work, you can force your output to behave as expected with PRE tags and approximations. This basically brings you back to your original question - counting linebreaks and characters and the likes, counting the lines by stripping the html output to determine how many characters really would go out (with the ob_* functions, remember though - you're just analyzing, don't leave the html out unless you really want to!). - except it changes to have you cater your output more to be predictable. Also, remember to account for htmlentities if that's an issue, & => &, etc. Really not a fun solution to entertain, IMO.

Good luck!

- Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to