This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Dreamweaver > February 2005 > OT PHP Form To Excel Spreadsheet
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
OT PHP Form To Excel Spreadsheet
|
|
|
| A site that I designed (with DWMX2004) for a client contains a monthly
drawing. They (not surprising to me) seem to be getting an overwhelming
amount of entries and they're seeking a solution to help them choose a
winner each month or they may shut down this, "service" if you will
altogether. I recieved an email from my client this morning:
"Is there anyway to set up some sort of system so that when someone enters
our monthly drawing, their information goes directly to an excel spreadsheet
so that at the end of the month, I just count up how many entries there are
and then pick a number at random and that's the winner. Currently, I copy
their info, paste it into an excel spreadsheet, then take that info again
and copy it and paste it into another demographics spreadsheet to kind of
see the kind of people that are visiting our site. We hope there might be
some way to capture all that info without me doing all the cutting and
pasting."
The current drawing page is handled through a form PHP page and emailed to
my client.
Is this more of an issue that can only be handled through a database? I'm
just a part time web designer so this may be out of reach for me.
Thanks for any help.
If there's a better place for me to post this please advise.
| |
|
| Not sure how you would do it in PHP. If I was doing this I would query
the database and write the output to XML on the users hard drive. From
there they can do anything really. I have a client that imports data
into an access database, this method works well for him.
If it was CF I could help, sorry. Perhaps someone with PHP know how can
do similar.
--
Cheers jojo
Team Macromedia Member Volunteer for Dreamweaver MX
http://www.webade.co.uk
----------------------------------------------------
Extending Knowledge, Daily.
http://www.communityMX.com/
Free 10 day trial
http://www.communitymx.com/joincmx.cfm
----------------------------------------------------
| |
|
|
"Tony" <webmaster@lbpstudios.com> wrote in message
news:cvir4t$ml9$1@forums.macromedia.com...
>A site that I designed (with DWMX2004) for a client contains a monthly
> drawing. They (not surprising to me) seem to be getting an overwhelming
> amount of entries and they're seeking a solution to help them choose a
> winner each month or they may shut down this, "service" if you will
> altogether. I recieved an email from my client this morning:
>
> "Is there anyway to set up some sort of system so that when someone enters
> our monthly drawing, their information goes directly to an excel spreadsheet
> so that at the end of the month, I just count up how many entries there are
> and then pick a number at random and that's the winner. Currently, I copy
> their info, paste it into an excel spreadsheet, then take that info again
> and copy it and paste it into another demographics spreadsheet to kind of
> see the kind of people that are visiting our site. We hope there might be
> some way to capture all that info without me doing all the cutting and
> pasting."
>
> The current drawing page is handled through a form PHP page and emailed to
> my client.
>
> Is this more of an issue that can only be handled through a database? I'm
> just a part time web designer so this may be out of reach for me.
>
> Thanks for any help.
>
> If there's a better place for me to post this please advise.
>
>
It would be possible with PHP to write the form values to a comma separated
file that you could then import to Excel.
Concantenate the form values into a string variable with comma separation.
Use the PHP functions fopen(),fputs(),fclose() to write the variable to the
file.
The PHP documentation is available at:
< http://www.php.net/docs.php >
HTH
-Rb
| |
|
| Thanks -Rb
Where exactly do I paste "fopen(),fputs(),fclose() " in the form and is that
all I need to do? If I need more info on this where can I find it at
PHP.net, what would it be called?
> It would be possible with PHP to write the form values to a comma
separated
> file that you could then import to Excel.
>
> Concantenate the form values into a string variable with comma separation.
> Use the PHP functions fopen(),fputs(),fclose() to write the variable to
the
> file.
>
> The PHP documentation is available at:
> < http://www.php.net/docs.php >
>
> HTH
>
> -Rb
>
>
>
| |
|
|
"Tony" <webmaster@lbpstudios.com> wrote in message
news:cvj36o$4sq$1@forums.macromedia.com...
> Thanks -Rb
> Where exactly do I paste "fopen(),fputs(),fclose() " in the form and is that
> all I need to do? If I need more info on this where can I find it at
> PHP.net, what would it be called?
>
A quick search of the web returns lots of examples:
<?php
extract($_POST);
if(is_writable('emails.csv'))
{
$fp = fopen('emails.csv','a');
$content = "$lastname,$firstname,$email,$format,$date\n";
fwrite($fp,$content);
fclose($fp);
}
else
{
echo'File is not writable';
}
?>
HTH
-Rb
>
> separated
> the
>
>
| |
|
| Anybody,
Where exactly do I paste "fopen(),fputs(),fclose() " in the form and is that
all I need to do? If I need more info on this where can I find it at
PHP.net, what would it be called?
>
> separated
separation.[color=darkred]
> the
>
>
| |
| Joe Makowiec 2005-02-28, 11:15 pm |
| On 28 Feb 2005 in macromedia.dreamweaver, Tony wrote:
> Where exactly do I paste "fopen(),fputs(),fclose() " in the form and
> is that all I need to do? If I need more info on this where can I
> find it at PHP.net, what would it be called?
They wouldn't go in the form; they'd go in the script which processes the
form. They are, respectively: fopen = File OPEN; fputs = File PUT
String; fclose = File CLOSE. So, in the script to process the form:
<?php
// Get input from the form
$myvariable = $_POST['myformfield'];
// Open the file
$handle = fopen("myfile.txt", "w");
// Write a line; fwrite = fputs
fwrite($handle, $myvariable);
// Close the file
fclose($handle);
?>
If you go to http://www.php.net/ and put, say, fopen in the search box on
the upper right, with "function list" selected in the dropdown, you'd
get:
http://www.php.net/manual/en/function.fopen.php
PHP manual pages like this usually have really good code samples on them.
--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|