Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = mysqli_connect( "localhost","root","","teste" ); // ◄■ CONNECT TO DATABASE.
- //$id_resp = (isset($_POST['id_resp']) ? $_POST['id_resp'] : '');
- //$id = $_SESSION['UtilizadorID'];
- //$data = (isset($_POST['data']) ? $_POST['data'] : '');
- $file = fopen("teste.csv","a"); //filename
- I change the POST variable to array variable with following output:
- array(8) { ["corp_resp&77&2&2017-09-07&80&76"]=> string(4) "0.00" ["corp_resp&78&2&2017-09-07&80&76"]=> string(4) "0.00" ["corp_resp&79&2&2017-09-07&80&76"]=> string(4) "0.00" ["corp_resp&80&2&2017-09-07&80&76"]=> string(4) "0.00" ["corp_resp&81&2&2017-09-07&80&76"]=> string(4) "0.30" ["corp_resp&82&2&2017-09-07&80&76"]=> string(4) "0.00" ["corp_resp&83&2&2017-09-07&80&76"]=> string(4) "0.00" ["corp_resp&84&2&2017-09-07&80&76"]=> string(4) "0.70" } array(1) { [0]=> string(4) "0.70" }
- if ( isset($_POST) ) {
- foreach ( $_POST as $key )
- $cr = explode( "&",$key );
- //mysqli_query( $con,"insert into tem (menuid,corp_resp_template,id,data,id_tem,menuIdPai) " .
- // "values ('{$cr[1]}','$value', '{$cr[2]}', '{$cr[3]}', '{$cr[4]}', '{$cr[5]}')" );
- I am introducing for database but i want to introduce to csv.
- I try in that way to csv file. But is empty $csv only with ;
- var_dump($cr);
- $csv = $cr[1].";".$value.";".$cr[3].";".$cr[4].";".$cr[5];
- var_dump($csv);
- //fputcsv($file,explode(';',$csv), ";");
- fclose($file);
- }
- else {
- echo "task option is required";
- exit;
- }
- echo "<center>AdicIonada com sucesso.</center>";
- echo '<br>';
- echo '<br>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement