0

I dont have problems with my code i only need a few clarifications:

I have done a file upload CSV that ignores the first line File Upload

PROBLEM:
After ignoring the first line i want only like 25 rows inserted;
What do i do?

Is this correct:
array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure [, string $escape]]]] ); 

can i use my $length?
Community
  • 1
  • 1
PULabs
  • 39
  • 2
  • 9

2 Answers2

0

Just use a for loop and ignore the first entry.

for ($i=0; $i<=25; $i++){
   $line = fgetcsv($fp);
   if ($i==0){
      continue;
   }

   insert_into_db(line);
}
Du D.
  • 5,062
  • 2
  • 29
  • 34
0

You can also use load INFILE statement.

LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES; 

The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed.

  • yea that's ok, but not what i wanted; i needed to limit the rows inserted/uploaded like amongs 1000 files in the csv only 400 should be inserted. That what i mean – PULabs Sep 15 '14 at 18:07