简体   繁体   中英

How can I export data from a HTML form to csv file using php

I have a HTML form constructed by a couple of drop down select fields. The submit button generates a string.

I need help exporting each string generated to a CSV file. My first thoughts are to take the string from the field and place it in a HTML table, then use a script for exporting it to a file.

I'd appreciate it if you can provide a working example.

I am very green in this, so please write slowly.

Thanks.

A CSV file is simply a comma seperated vector.

So each string can be written to a file so that they are separated by commas if you want them in separate columns, or by carriage returns if you want them on separate lines.

The csv export didn't work, so i am trying to print the text input (that i am generating) to a text area, one by one and it works fine.

The problem now is that i want to place a "br" after each link i move to the text area. any ideas? here is my code:

<input name="result" size="70" class="result" type="text" ></input>
<input type="button" value="Add The Link" onClick="addtext();"></p>
<textarea style="width:509px;" name="outputtext"></textarea><br><br>
<input value="Clear" type="reset">

and in the head are is:

<script language="javascript" type="text/javascript">
function addtext() {
    var newtext = document.cwm1.result.value;
    document.cwm1.outputtext.value += newtext;
}
</script>

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM