This is the first time I'm trying to do this, and I just can't get it to work. I have a CSV file in this format...
Code: Select all
Sport_Grey,sport_grey.gif
PoliceBlue,policeblue.gif
Navy_Slate,navy.gifThe question is how do I use fgetcsv() for each of these values? I need to populate the DB like...
insert into colours values (color_name,color_file), where these are the two fields contained in the CSV.
Here is what I have now, from the PHP manual...
Code: Select all
$row = 1;
$handle = fopen("colours.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);Any help is appreciated!
Philip