Hello everybody,
I am trying to simply remove the 1 line of my csv file upon importing, so the first line in my DB is not the header line.
i've pulled the data out of the file previously, but i'm hitting a problem when actually uploading each line into the db.
here is the code loops and runs each individual import:
$lines = 0;
$queries = "";
$linearray = array();
foreach(split($lineseparator,$csvcontent) as $line) {
$lines++;
$line = trim($line," \t");
$line = str_replace("\r","",$line);
$line = str_replace("'","\'",$line);
$data = explode(",",$line);
$import = "INSERT into `".$table_name."`
(***FIELD NAME*****`)
values('***VALUES*****)";
//execute the mysql query
mysql_query($import) or die(mysql_error());
}
i guess i see 2 options here:
1) removing the first line from $csvcontent (then writing back to the file)
2) simply skipping the 1st iteration of this foreach. This is what i'm currently unable to do.
any help would be appreciated!
-michael