By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,771 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,771 IT Pros & Developers. It's quick & easy.

Save the current (PHP) page as an HTML file 'to' the client?

scubak1w1
P: 53
Hello,

I have been Googling for a bit now as to how to let the user save the current page via a 'clickable icon' to an HTML file (i.e., on the client side.)

That is, I am presenting a lot of analytical results (from a PostgreSQL database) and the parameters the user selected on a page as a series of table, etc - with the number of results and hence the number of "little tables" being related to what parameters they chose.

The results_analytical_detailed.php page presents well...

I have added an icon to save the results, unformatted, as a CSV, works just hunky dory...

aside - I discovered if you make a file with a \t delimiter and \n for the CRs and give the file a *.xls ending, Excel knows how to open this! Users may not have Excel, but in my setting most of them do... and I don't have to write code to strip out all the commas in a bibliography list the user parsed - and indeed would not want to - if I instead wanted to have available as a CSV for the client's download... well, I was happy to find this, even if you knew about it already! :-)

I have added an icon to save the results as an HTML, so they can come back to later, etc, etc (and open in MS Word if they must ;) )

What approach could someone suggest to save the current page as an HTML file to the client?

Note that I have added an icon to save the results as a PDF, and based on a couple of replies to another post I am off to look at how to do this now! :-) What a resource! :-)

Thanks in advance:
GREG...
Mar 6 '08 #1
Share this Question
Share on Google+
6 Replies


dlite922
Expert 100+
P: 1,584
Why can't they just use File -> Save ???

it works you know!

PHP is sever side. the client never sees the PHP code. Its HTML that's generated for the browser. Using the save feature of the browser, you can save a copy of that HTML (and depending on your choices) save all the images as well so that it can be opened and it will look the same.

I suggest you open a new window that contains only the data they need (no menu/images that make up the site or frame) and instruct them to go to File-> Save.

Good luck.
Mar 7 '08 #2

scubak1w1
P: 53
They are managers... they wanted a button, very Dilbertesque... :-)

But thanks... that is what I ended up doing... in small but distinct red text at the top of the page... :-)

Note that I tried using headers and disposition but as you stated/know the client sees the HTML 'version' of the page, so they would get the PHP code as HTML text like [PHP]print "<p>Some paragraph text</.p>";[/PHP] or whatever... I did some reading on using the document object model in javascript or using php output control... ugh... too much for me to learn right now as I have too many other things to do, they can use damn file menu! :-)
Mar 7 '08 #3

hsriat
Expert 100+
P: 1,654
They are managers... they wanted a button, very Dilbertesque... :-)

But thanks... that is what I ended up doing... in small but distinct red text at the top of the page... :-)

Note that I tried using headers and disposition but as you stated/know the client sees the HTML 'version' of the page, so they would get the PHP code as HTML text like [PHP]print "<p>Some paragraph text</.p>";[/PHP] or whatever... I did some reading on using the document object model in javascript or using php output control... ugh... too much for me to learn right now as I have too many other things to do, they can use damn file menu! :-)
You may also add something like Save a PDF and generate on the fly PDF from the server side when that button clicked.
Mar 8 '08 #4

scubak1w1
P: 53
You may also add something like Save a PDF and generate on the fly PDF from the server side when that button clicked.
Thank you... I have been looking into that... what is the best method to make a PDF in this fashion? Just a general guide of course.

I have been looking at a bunch of methods, but it looks like I would need to 'reconstruct' the page as a series of code pieces rather than just "print"...
Mar 9 '08 #5

hsriat
Expert 100+
P: 1,654
Thank you... I have been looking into that... what is the best method to make a PDF in this fashion? Just a general guide of course.

I have been looking at a bunch of methods, but it looks like I would need to 'reconstruct' the page as a series of code pieces rather than just "print"...
That it is, you have to reconstruct the whole data.
Try fpdf.


Harpreet
Mar 10 '08 #6

scubak1w1
P: 53
thank you... I will do that...

any thoughts on PDFlib, the OS version? (the licensing not withstanding...)
Mar 10 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.