sql - PHP - Reading multiline CSV -


i've had no issue first line of csv being read upon upload , inserted database, multi line task having issues. can print array dump on web page shows lines of csv it's still inserting first line database. i've worked code around , came this:

if(isset($_post['submit'])) { ini_set('auto_detect_line_endings', true);  $file = $_files["file"]["tmp_name"]; $handle = fopen($file, "r");   while(!feof($handle)){ $filesop = print_r(fgetcsv($handle, 0, ","));  } $coldata = array(); 

i have code calling queries (there other queries after this, main 1 puts staging table):

 $tablenames = array("staging"/*,"clients","meters","tests","costs","workorders"*/);  for($tableno = 0;$tableno < sizeof($tablenames);$tableno++){ $q = ""; $q2 = ""; $q3 = ""; $q4 = ""; $q5 = ""; $q6 = ""; $col_list = '`'.str_replace(',','`,`',$table_cols[$tableno]).'`'; $q .= "insert ".$tablenames[$tableno]." (".$col_list.") values ("; $last_id = mysqli_insert_id($connect); $cols = explode(",",$table_cols[$tableno]); $data = array(); foreach($cols $key => $fldname) {     $data[] = "'".$coldata[$fldname]."'"; }  /*insert staging table - inital csv upload*/ $q .= implode(",",$data).");"; 

am doing wrong in queries that's causing not insert lines of csv db?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -