header("Content-Type: text/html; charset=utf-8");
$link = mysqli_connect("127.0.0.1", "root", "root", "test");
if (!$link){echo"";}
$link->query("SET NAMES UTF8");
$file=fopen("sss.csv","r");
$a=1;
while(! feof($file)){
$data=fgetcsv($file);
if($a=1) continue;
if(!is_array($data)) continue;//如果不是数组就跳出循环
$sql=$p="";
foreach($data as $val){$sql.=$p."'".mb_convert_encoding($val,'UTF-8','GBK')."'";//foreach遍历数组
$p=",";
}
$sql="INSERT INTO testt (aaa, bbb, ccc) VALUES (".$sql.")";
$link->query($sql);
$a.=1;
}
fclose($file);
echo "ok";
?>