触摸屏租赁
Touch screen rental
广告机租赁
Advertising rental
机器人租赁
Robot leasing
 当前位置:首页 > > PHP中将Excel数据导入到Access
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<?
error_reporting(0);
ob_start();
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("db/Fang.mdb");
$conn->Open($connstr);
$conn2=new com("adodb.connection");                        
$connstr2="Driver={Microsoft Excel Driver (*.xls)};DBQ=".realpath("excel/Fang.xls");                        
$conn2->open($connstr2);
$sql="select * from [Sheet1$]";//Excel 表下面的选项卡
$rs=$conn2->execute($sql);
while(!$rs->eof){ 
$country = $rs->Fields(0)->value;
$mobile = $rs->Fields(1)->value;
$conn->execute("INSERT INTO [zhenya] (country,mobile) VALUES ('$country','$mobile')");
$rs->movenext;
echo "正在插入 ".sql."<Br>"; 
}         
?>  
</body>
</html>

工作室地址:重庆石桥铺电脑城B座 | 微信:z35544216 | 网址:www.35544216.com