$csv_directory = opendir("admin/csvfiles/");
$number_of_files = 0;
While($filename = readdir($csv_directory)) {
If ($filename != ".." && $filename != "." && $filename != "_vti_cnf") {
$local_file = "admin/csvfiles/" . $filename;
$fp = fopen ("$local_file","r");
while ($data = fgetcsv ($fp, 1000, ",")) {
$import="INSERT INTO deliveries VALUES ('', '$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]','$data[17]','$data[18]','$data[19]','$data[20]','$data[21]','$data[22]','$data[23]')";
mysql_query($import) or die(mysql_error());
}
unlink($local_file);
fclose ($fp);
$number_of_files++;
}
}
|