I have a form that generates an SQL statement, based on the users choices. It is functioning much like the report wizard in MS Access. On the last step, I have all the data, and the dynamically generated SQL query, but I need a way where they can download it as a file. How should I go about this?
Currently I have three buttons called
'View Results' (which just shows HTML generated results, that is easy - they just open up in a new tab)
'Download CSV' (preferably I would like this when clicked to just act like a normal download of a file, the user gets prompted to save as etc by the browser)
'Download PDF' (same as CSV)
At the moment when the CSV button is pressed a new tab opens up with export_report.php,
which outputs CSV style report data.
How can I achieve the desired results with the CSV and PDF button? I have all the data and information I need to generate either but I am unsure how to proceed forward with this.
For the generation of the PDF you could use fpdf witch allows you to build a pdf from php.
For the generation of the CSV you only have to adjust the headers. Here is a link that explains how this works: csv generation.
Related
I am trying to generate a report based on user input from a form in html. As of right now, everything works. Except when I generate the report, the url of the newly opened tab contains the location and the name of my php file. Obviously, this report won't be accessible once the user closes that tab.
Is there any way I can store this file on my server and specify a path for it(for each user)?
Or just generate a pdf file out of it? I tried using some libraries but they don't fully support bootstrap.
I have a .xml file in my computer and i want it to be inserted in a single column and single cell of a sql table corresponding to serial no.s so that i can create a link on web page that would be directly downloadable from web page when clicking on it .I've searched everywhere but what i am getting is insert xml data in a table or how to upload a file on web page .
But i want them to be already uploaded on web page and when clicking on a link it will be directly downloaded on user,s local machine. So for this , I've to put those files in a column corresponding to their serial no.s then using php i can make those files downloadable to user machine .How is this possible have any idea...???
Go to this link "http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx"
This is a tutorial where you can insert xml file into database and also can create its downloadable link .This may help you.
In such case I would encode whole content of XML file using base64 before inserting into single database cell. And when using direct link use a php script which selects that cell, decodes data and simply outputs as xml.
If xml files are quite big, it is recommended to use gzip for compressing data before encoding with base64.
Did I understood your question correctly?
i have create 2 pages.
report.php
printForm.php
report.php is simple php page and printform is generate pdf page
when i generate pdf page not generate in online server and when i use local server so completely generate pdf file
report.php is filterig data page and that filtered data print on pdf page
so i have used one hidden box and hidden box value are select query and transfer select query on printForm.php now i fetch data on pdf page but my code is correct so this page complete execute on local server and generate pdf but when i generate pdf on online server so that time all selected value is not print so plz
plz help me
From what i understand...
If everything works fine on your local server, and does'nt perform as expected (Especially issues related to file creates, in your case PDF files) - check your permissions.
Most of the time you might not be having permissions to create a PDF file (if you are saving it first to a disk folder).
I am using FPDF to create a pdf document in an iFrame... During the pdf creation the script communicates and gets a lot of data from the server, and then I would like to display a progress bar.. That is why I have put the php generator in an iFrame.. then my plan was that the php script could send the looped data to the parent window..
e.g. every time a loop is made it says $count++;, then I know how many loops it has gone through, and I already know that it is going to limit the rows to the first 200 rows.. Then I would like to display the looped data in the parent widow like so: $count of §goal has been generated successfully!.. At the moment I am using jQuery, where I ask the php to echo some jQuery script every time a loop is made to display the results like so window.parent.count($count, $goal);.. Count in the parent winodw and it actually works well until the PDF has to be shown.. then I get an error message that tells me that the script is unable to display the PDF because the page already has outputted data..
Does anybody know how to make the PHP to send the data to the parent window, so I prevet the using of echo?
Sorry for my bad english.. if wished I can try to upload my script later for you to see...
I do it a bit differently...
I also wrote an application in which the PDF generator needs to fetch a rather large amount of data, so the generation takes a few seconds.
I use jQuery to fetch a php-page in the background. During this download, the screen turns gray and displays a classic "please wait"-circle. The only output that the php-file generates is an "OK" echo, together with a file link, when the generation has been completed. Instead of displaying the file inline, I save the PDF in a folder ($pdf->Output('filename.pdf','S')) and offer it as a download using the provided link and the jQuery-callback.
I hope you understand what I mean. Maybe this thought will help you a bit further.
EDIT: Don't know if this will work, but I just thought of it...
You could save the file and output the filename. Using jQuery, you could then refresh the contents of the iframe to fetch a page in which you display the already saved PDF inline...
I have a Google spreadsheet with data that will be updated on a weekly basis. I need to bring this data into a HTML table on my website.
Rather than running it through a CSV to HTML converter each time and having to update the HTML code each time, is there a way for me to use PHP or Javascript to look up the Google Spreadsheet URL and convert the data to HTML Table tags without me needing to alter the code each time?
You may be interested in GD API (description concerning spreadsheets).
Default download format is html. Write a script and run in using CRON once a day to pull newest version of you document.
Open your spreadsheet, go to File > Download as > Web page (.html, current sheet)
That should open a link in a new window. This should automatically update when you reload the page after the data has been edited. In jQuery, you can use the .load function to load the data into your page.