PHP读取ACCESS数据到MYSQL的代码_PHP
程序员文章站
2022-06-13 17:47:54
...
复制代码 代码如下:
header('ontent-Type:text/html;charset=GB2312');//避免输出乱码
$dbhost ="localhost";
$dbuser ="root";
$dbpassword = "123456";
$dbname = "139miaosha";
mysql_connect($dbhost,$dbuser,$dbpassword) or die("error!");
mysql_query("set names 'gbk'");
mysql_select_db('139miaosha');
$conn = new com("ADODB.Connection");
$connstr="DRIVER=Microsoft Access Driver (*.mdb);DBQ=F:/wamp/www/miaosha/ruichao858.mdb";
$conn->Open($connstr);
$rs = new COM("ADODB.RecordSet");
$rs->Open("select * from News where bigclassname='装修课堂'",$conn,1,3);
while(!$rs->eof){
switch ($rs->Fields[4]){
case "装修顾问":
$sclass=1;
break;
case "厨卫空间":
$sclass=2;
break;
case "家具物语":
$sclass=3;
break;
case "电器工程":
$sclass=4;
break;
case "居饰风景":
$sclass=5;
break;
case "材料广角":
$sclass=6;
break;
default:
$sclass=1;
}
if ($rs->Fields[6]){
$spic="";
}else{
$spic=$rs->Fields[6];
}
if ($rs->Fields[7]){
$user="";
}else{
$user=$rs->Fields[7];
}
if ($rs->Fields[9]){
$hits=1;
}else{
$hits=$rs->Fields[9];
}
$sql="insert into rc_news(n_title,n_content,n_bclass,n_sclass,n_pic,n_spic,n_user,n_hits,n_audit) values('".$rs->Fields[1]."','".$rs->Fields[2]."',1,".$sclass.",'','".$spic."','".$user."',".$hits.",1)";
$result=mysql _query($sql);
//echo $rs->Fields[1];
//echo "
";
$rs->Movenext(); //将记录集指针下移
}
$rs->close();
?>
header('ontent-Type:text/html;charset=GB2312');//避免输出乱码
$dbhost ="localhost";
$dbuser ="root";
$dbpassword = "123456";
$dbname = "139miaosha";
mysql_connect($dbhost,$dbuser,$dbpassword) or die("error!");
mysql_query("set names 'gbk'");
mysql_select_db('139miaosha');
$conn = new com("ADODB.Connection");
$connstr="DRIVER=Microsoft Access Driver (*.mdb);DBQ=F:/wamp/www/miaosha/ruichao858.mdb";
$conn->Open($connstr);
$rs = new COM("ADODB.RecordSet");
$rs->Open("select * from News where bigclassname='装修课堂'",$conn,1,3);
while(!$rs->eof){
switch ($rs->Fields[4]){
case "装修顾问":
$sclass=1;
break;
case "厨卫空间":
$sclass=2;
break;
case "家具物语":
$sclass=3;
break;
case "电器工程":
$sclass=4;
break;
case "居饰风景":
$sclass=5;
break;
case "材料广角":
$sclass=6;
break;
default:
$sclass=1;
}
if ($rs->Fields[6]){
$spic="";
}else{
$spic=$rs->Fields[6];
}
if ($rs->Fields[7]){
$user="";
}else{
$user=$rs->Fields[7];
}
if ($rs->Fields[9]){
$hits=1;
}else{
$hits=$rs->Fields[9];
}
$sql="insert into rc_news(n_title,n_content,n_bclass,n_sclass,n_pic,n_spic,n_user,n_hits,n_audit) values('".$rs->Fields[1]."','".$rs->Fields[2]."',1,".$sclass.",'','".$spic."','".$user."',".$hits.",1)";
$result=mysql _query($sql);
//echo $rs->Fields[1];
//echo "
";
$rs->Movenext(); //将记录集指针下移
}
$rs->close();
?>
上一篇: 设计模式(22)-Strategy Pattern
下一篇: 使用VisualVM进行Java应用的性能测量 JavaSAP云平台SAP Cloud PlatformCloudCloudFoundry
推荐阅读
-
foreach - PHP 导入文本文件的正则表达式提取部分内容 变成数组 然后存入到mysql数据库中
-
linux php mysql数据库备份实现代码_PHP
-
PHP使用mysql_fetch_row查询获得数据行列表的方法
-
1亿条数据如何分表100张到Mysql数据库中(PHP)_PHP
-
使用PHP导出Redis数据到另一个Redis中的代码
-
基于PHP读取TXT文件向数据库导入海量数据的方法_php实例
-
php 提交数据到mysql 出现数据错误
-
php中使用DOM类读取XML文件的实现代码
-
求php+mysql实现快讯信息的增删改查代码
-
基于tp5小程序登录的实现 demo版本 获取code 返回token 解密微信数据信息 和验证数据来源真实性(包含小程序前端和php后端代码 )