Page 1 of 1
Can PHP be used to print a portion of a page?
Posted: Wed Feb 18, 2004 11:32 pm
by buddybear
I'm thinking of setting up a page that has 3 sections separated by dividers. I would like the visitor to be able to choose a section or sections on a page and only print sections they want.
Am I on the right track with PHP or is there a better way?
I'm new to this. Thanks in advance.
Posted: Thu Feb 19, 2004 8:20 pm
by nigma
Yea, you should be able to do that. Are you wondering what functions to use? or how you would do it logically?
To output the data i'd probably use print or echo's heredoc syntax. Depending on how much data will be displayed per section you might also want to look into ways to buffer / compress the data.
Posted: Thu Feb 19, 2004 8:45 pm
by buddybear
I'm a total novice with PHP. It was a thought to see if it be done. I'll checkout some tutorials. If anyone can point me in the right direction it would be appreciated.
Posted: Thu Feb 19, 2004 9:06 pm
by Illusionist
nigma, i think he meant print it through a printer. BUT, he could do it your way, and then the person just print that page that loads.
Posted: Fri Feb 20, 2004 6:18 pm
by nigma
If he did want it to run through a printer he would have to use a client-side scripting language, in which case he's posting in the wrong forum. No worries though if that is what you meant, I'm not going to chew you out

Posted: Fri Feb 20, 2004 6:33 pm
by nigma
Oh, and to actually address your question, here is how I would go about doing this.
First: Find out which sections the user wants to see.
Second: Find a way to store the section names / numbers in a variable. This will simplify the next step.
Third: Output the sections to browser. I'd probably do this by first using a switch statement to find out which sections the user has said he/she wants to see, then using echo's heredoc syntax (
http://us2.php.net/echo) to actually put the data on the screen.
Feel free to ask many more questions.
Hope this helps?
Posted: Fri Feb 20, 2004 9:50 pm
by buddybear
Thanks for the information. As a beginner it sounds like it will be more than I can handle now. I think I'll put some time into learning the basics first.
I'm sure I'll have questions as I progress.