php - Stop insert of first row from CSV
66
Im currently importing from a CSV and i cant seem to figure out how to stop the insert of the first row.
if ($_FILES[csv][size] > 0) {
//get the csv file
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");
//loop through the csv file and insert into database
do {
if ($data[0]) {
mysql_query("INSERT INTO TABLE (id,type) VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."'
)");
}
}
while ($data = fgetcsv($handle,0,",",'"'));
echo "Done";
}
Any help would be awesome!
Answer
Solution:
If all you are trying to do is skip the first then drop the
do
and turn your loop into a regularwhile
and make sure to callfgetcsv()
once before the loop.Answer
Solution:
Before looping call
fgetcsv
once -