php导入execl...
时间:2010-08-17 来源:qiyufeifan
<?
//excel文档导入mysql数据库
$connect = @mysql_connect("localhost","root","123456") or die("数据库连接失败!");
@mysql_select_db("bbb",$connect) or die(mysql_error());
@mysql_query("set names gbk");
$temp = file("E:\sp.csv");
for($i=0;$i<count($temp);$i++){
$string = explode(",",$temp[$i]);
$q = "insert into sp(a,b,c,d,e,f,g,h,i) values('$string[0]','$string[1]','$string[2]','$string[3]','$string[4]','$string[5]','$string[6]','$string[7]','$string[8]')";
@mysql_query($q);
if(!mysql_error()){
echo "Success!!!";
}else{
echo "fail!!!";
}
}
?>
相关阅读 更多 +