Hi all
I have the following code which reads the contents of a CSv file and inserts the data into my table within my database.
This is all working great, but now I need to be able to run an update query after each insert query which takes the contents of the 2nd column in my CSV file and updates a field against the record just inserted. Hope that makes sense.
Can someone help me out and maybe amend the code?
$fcontents = file ('./test.csv');
for ($i=1; $i<sizeof($fcontents); $i++) { // ignore the header row
$line = trim($fcontents[$i], ',');
$arr = explode(",", $line);
$insertquery = "INSERT INTO mytable (field1, field2, field3) VALUES ('". implode("','", $arr) ."')";
mysql_query($insertquery);
// now I need to update a field in the record above with the value of the 2nd column of my csv file
}
Any suggestions would be gratefully appreciated
K