"; // loop through results with fgetcsv() function while(($data = fgetcsv($handle, 1000, "\t")) !== FALSE) { // populate field vars just to make it easier to work with .. // you could access the $data[] array directly in the sql if you want $field1 = $data[0]; $field2 = $data[1]; $field3 = $data[2]; $field4 = $data[2]; // etc ... // build your sql statement $sql = "insert into table set testid='1', category='foo', field1='".$field1."', field2='".$field2."', field3='".$field3."'"; //if($x >0) $result = mysql_query($sql); if($x >0) echo "