Hi,
I want to allow the user to select a CSV file to upload details into my Db, along with a seprate variable, which is a session variable called $vendorid, this is set when they login.
So far I have the following, how can I insert the $vendorid in each row, along with the data from the text file?
The Db has 11 columns, but the text file has 10, I want to set the 11th column to $vendorID for each row in the text file....
Code so far:
for($i=0; $i<sizeof($fcontents); $i++) {
$line = trim($fcontents[$i]);
$arr = explode(";", $line);
#if your data is comma separated
instead of tab separated,
change the '\t' above to ','
$sql = "insert into master values ('".
implode("','", $arr) ."')";
mysql_query($sql);
if(mysql_error()) {
echo mysql_error() ."<br>\n";
}
Thanks!