Hi,
Right I know there is a function called fgetcsv that I can use to read a csv file into an array, so thats not the problem.
What I have got is a row of headers, that name each of the fields in the CSV file. What I want to be able to do is to refer to the fields as these names if possible
For instance this is my code now:
while($data = fgetcsv ($fp, 1024, ","
) {
$CompanyName = AddSlashes(Trim($data[1]));
}
As I have got the field names at the top of the file, I would like to be able to refer to the fields using the names supplied like this:
while($data = fgetcsv ($fp, 1024, ","
) {
$CompanyName = AddSlashes(Trim($data["CompanyName"]));
}
I have seen most of the suggestions about importing it using the mySQL command LOAD Data, but I want to be able to assign the information coming in to the logged in user, and be able to split the data across various tables.
Is this possible?
Tony
Right I know there is a function called fgetcsv that I can use to read a csv file into an array, so thats not the problem.
What I have got is a row of headers, that name each of the fields in the CSV file. What I want to be able to do is to refer to the fields as these names if possible
For instance this is my code now:
while($data = fgetcsv ($fp, 1024, ","

$CompanyName = AddSlashes(Trim($data[1]));
}
As I have got the field names at the top of the file, I would like to be able to refer to the fields using the names supplied like this:
while($data = fgetcsv ($fp, 1024, ","

$CompanyName = AddSlashes(Trim($data["CompanyName"]));
}
I have seen most of the suggestions about importing it using the mySQL command LOAD Data, but I want to be able to assign the information coming in to the logged in user, and be able to split the data across various tables.
Is this possible?
Tony