Jump to content

how to save inquiry form in csv


pixeltrace

Recommended Posts

Writing an example right now.. will edit post with results

 

Normally I would build form results in to an object and do this a bit different, but a simple way of doing it is as follows:

 

<?php
/**
* @author: nick stinemates
*/

function array_to_csv($array) {
/**
 * in array,
 * out csv list
 * 
 * i.e $x = array_to_csv(array("apple", "orange"));
 */

$ret = "";

foreach ($array as $val) {
	$ret .= $val . ",";	
}	
return $ret;
}

$date = $_POST['date'];
$name = $_POST['name'];

.
.
.
.

$arr = array($date, $name, $nVal);

$fh = fopen("some.file", "w+");
fwrite($fh,array_to_csv($arr));

?>

hi,

 

what i mean is each values taken from the form must be separated in columns.

 

let say i have column

 

brand, product  model, product type, serial no, warranty period....... so on.

 

if the form is submitted, how can i save it on the csv that

the value for brand name, product model, product type,....... will be inserted

in there respective columns?

 

 

hope you could help me with this.

 

thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.