Can PHP be used to print a portion of a page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
buddybear
Forum Newbie
Posts: 3
Joined: Wed Feb 18, 2004 11:32 pm

Can PHP be used to print a portion of a page?

Post 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.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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.
buddybear
Forum Newbie
Posts: 3
Joined: Wed Feb 18, 2004 11:32 pm

Post 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.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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 :)
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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?
buddybear
Forum Newbie
Posts: 3
Joined: Wed Feb 18, 2004 11:32 pm

Post 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.
Post Reply