I want the results of a form to be displayed in a spreadsheet after the user selects submit. A tutorial would be nice or a site that offers a tutorial would be awesome as well.
Can someone please show me how to get a spreadsheet from a php form?
Edit: I found a more complicated example but I think it is what you are looking for:
http://www-128.ibm.com/developerworks/op...
You can put it into a CSV file and then open it in Excel. The problem is that you'll lose all your formatting, but it is a simple way to accomplish the task.
Setup a text file called "form.csv". In the first line of the file, put each column heading seperated by commas with NO spaces (,). Setup your form with the names of the form fields the same as the column headings in the exact same order as well. Then, press the enter key once. The file must be on the same directory as the script. Then, use this script to process the form and output the data to the file:
%26lt;?php
$body = "";
foreach($_POST as $field =%26gt; $value) {
$body .= "$value,";
}
$body .= "\n";
$fp = fopen("form.csv", "w");
fwrite($fp, $body);
fclose($fp);
?%26gt;
So, if you had form fields with the names "name", "email", and "comment", you would set up your CSV file like this:
name,email,comment
[Values will go here]
Hopefully, this should work out but I can't say that it will. Test this on your server to see if it works.
Reply:Tons of info here: http://www.google.com/search?q=php+excel...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment