pixeltrace Posted July 16, 2007 Share Posted July 16, 2007 hi, i need help. i have a project wherein inquiries must be logged in a csv form. my problem is i have no idea how to do it. sample page is this http://mango.resonance.com.sg/memoryworld/index.php?option=com_warranty hope you could help me with this. thanks! Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 Take a look at fopen() and fwrite(). Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 16, 2007 Share Posted July 16, 2007 If csv = comma separated variable, then I suppose you're meant to concatenate all form data with commas between variables and then you're supposed to ... maybe Thorpe's got it ... who knows. Quote Link to comment Share on other sites More sharing options...
keeB Posted July 16, 2007 Share Posted July 16, 2007 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)); ?> Quote Link to comment Share on other sites More sharing options...
pixeltrace Posted July 16, 2007 Author Share Posted July 16, 2007 Hi, Thanks! how will it be if each field item should be separated in column not commas? Quote Link to comment Share on other sites More sharing options...
keeB Posted July 16, 2007 Share Posted July 16, 2007 I don't understand your question. Quote Link to comment Share on other sites More sharing options...
pixeltrace Posted July 16, 2007 Author Share Posted July 16, 2007 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! Quote Link to comment Share on other sites More sharing options...
keeB Posted July 16, 2007 Share Posted July 16, 2007 Look at what my code does, how it works.... its completely up to you the order it goes in. You have what is necessary, go ahead and finish it Quote Link to comment Share on other sites More sharing options...
pixeltrace Posted July 16, 2007 Author Share Posted July 16, 2007 thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.