PDA

View Full Version : Advice Needed


kraftomatic
04-21-2004, 05:23 PM
Hey All,

I have a project and I'm not sure what the best way is to tackle it. I was hoping for some advice.

I have a form with approximately 20-25 field values - text, numbers, date fields, drop downs, etc. etc.

When this form is filled out and submitted, I am planning on sending it to a mySQL db to store the values, as there will end up being 100-1000 of these forms filled out.

What I need is all the data from the filled out forms in a particular day (for example) to be spit out into a comma delimited, text file, that can later be imported into another foreign db/app. I don't have to worry about that app - just getting the records into a CSV/Text file.

What do you guys think would be the best way to go after this? My idea seems a bit messy, in that I would have a page where the user would specify three fields:

1) Start Date (range to capture the data)
2) End Date
3) File Name (where "x" number of records will be written).

I'm not exactly sure the best way to actually write out this text file, so that's a bit of a question mark. I'm also not sure if this is the best solution.

Any thoughts and suggestions would be appreciated.

Thanks.

raf
04-21-2004, 08:29 PM
I don't realy see the problem. With mySQL you can create the txt like

SELECT your variables come here INTO OUTFILE ' yourfilename.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM yourtable WHERE yourdatevariable >= Startdate and yourdatevariable <= Enddate ;

kraftomatic
04-21-2004, 09:26 PM
Thanks - that is pretty simple. I think I was looking to make it more complex than it needed to be.

I simple page with the start date, end date, and file name, which will automatically generate the file for them.

I'll start looking for this, but can I just add a 'c:\' to have the file copied locally to the machine? Or does that not work?

raf
04-21-2004, 10:28 PM
but can I just add a 'c:\' to have the file copied locally to the machine
You mean to the clients machine?

Hmm. Imagin you could do that. what would prevent you then to dump whatever virusses on whatever visitors machine?
To get it on the clients machine, you either need to have him download it, or you need to ftp it to their machine (if they have an ftp-site running on the client) or you need to attach it to a mail and send it to their mailbox. If they have a mailclient that support rule-building, then they could automaticaly detach it to the directory they want.
In any case, you'll need to store the page inside a folder on the server, and then ftp it or display a page with a downloadlink for that file or attach it to a mail. And then you best remove the file from your server.