PHP to produce a csv file

Hi. I do our in house database development and I want to add a little bit of web functionality. Specifically, I want to ultimately be able to create a simple personalised php order form and its corresponding script by exporting from our database and uploading it to our webspace. The php form will be accessible by a customer and will be a simple listing of the products we sell to him, together with a quantity field. The reason I need to generate custom forms and scripts is that our various customers have different product names and pack sizes.

The form would have a simple array as follows:
Product 1 Prod1QTY
Product 2 Prod2QTY
Product 3 Prod3QTY

and so on. When the customer clicks submit, I just want the data written to a simple CSV file that I can then import into our system. The csv file would have the following format:

Description; QTY (file header with field names)
Product 1;Prod1QTY (new line indicates new record)
Product 2;Prod2QTY
Product 3;Prod3QTY

The labels Product 1, Product 2 and each QTY field would be given unique values in the form by our database export routine. I have tried using a software package (SIMFATIC) to generate sample code but there appears to be no control of the csv file format. I know this is pretty straightforward in principle, but I don’t have any PHP scripting experience. Can anyone help?

Thanks

Are you able to provide an sql dump of your table structure and a few sample records? I am thinking there is an easier way to accomplish what you want. I just want to make sure I am clear on exactly what that is. I am confused as to why you need the form data to go to a csv file and then have to hand import it.

Also, how many customers do you currently have and how many do you expect it could ever be?

simple enough to do, try this out http://code.stephenmorley.org/php/creating-downloadable-csv-files/, just take out the headers and make your changes.

*richei, that tutorial uses deprecated code.

Still does the job, and the cvs functions aren’t going away.

Sponsor our Newsletter | Privacy Policy | Terms of Service