0

hi,

i was wondering of a simple way to generate a pdf & excel spreadsheet from a php form and mysql table with data in it?

any help would be great.

many thanks

4
Contributors
9
Replies
11
Views
7 Years
Discussion Span
Last Post by andydeans
0

hi,

i was wondering of a simple way to generate a pdf & excel spreadsheet from a php form and mysql table with data in it?

any help would be great.

many thanks

to export to xl just include the header and write HTML with tables

<?php
$filename ="excelreport.xls";
$contents = "testdata1 \t testdata2 \t testdata3 \t \n";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $contents;
 ?>

to export to pdf, you have many ways. Use phps built in pdf support, a library that php supports, or just an HTML to PDF converter like http://www.rustyparts.com/pdf.php

0

Hi sorry for the delay.

The requirement has slightly changed from what i had originally thought.

I have looked at all the links and other docs on net but this exports the html page to pdf.

What i need to do is:

On my page i have quite a long application form. i need to prepopulate the info from the mysql database after it has been inserted to a pdf doc which has all the questions on it and the answers come from the database.

so basically in my app currently you can view the clients details from the inserted form which is fine, but how can i click a button which then adds the data into a pdf document?

i looked at other solutions on net which talk about other fdf files but not sure if that is the best way to go.

if anyone has any experience of implementing something i would appreciate and opinions on it.

many thanks

0

Not clear on your problem. Is this an update process where you want to display the data, allow changes and then create a new PDF? If that is the case why get complicated and try to change the existing PDF? Just create a new one and overwrite the old one (or create it under whatever name the user chooses)? If I am misunderstanding the situation then you need to explain it better.

0

hi sorry, if i was not clear.

basically i need to write data from my mysql database which is display on screen to a pdf which either creates the whole pdf with the field name for example:

title: dynamic data from database

or it writes to a pdf which has the fields in it already and the data just inserts into the blank spaces on pdf.

hope you can help.

many thanks

0

There is support built into PHP to create PDF files, but I found it easier to display the report and then create a PDF file from that using HTML2PDF. For more info see:
HTML2PDF

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.