Hello,
I am using this script to import a csv file to a Mysql db. It works fine apart from the fact that it imports everything it finds in the csv file separated by ; (what it supposed to do). I need some help on how to distinquish the values in the csv file.
Specifically
CSV FILE :
field1;field2;
myname;mysurname;
I need some way to distinquish that "myname" is the value of filed "field1" and accordingly for "field2 " and "mysurname"
Any suggestion would be appreciated
Thanks
<?
if(isset($_POST['filename']))
{
$filename=$_POST['filename'];
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE)
{
$import="INSERT into TABLENAME(name, surname, address) values('$data[0]','$data[1]','$data[2]')";
mysql_query($import) or die(mysql_error());
}
fclose($handle);
print "Import done";
}
else
{
print "Import not done";
}
?>