PHP讀取ACCESS數(shù)據(jù)到MYSQL的代碼
<?php
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 "裝修顧問(wèn)":
$sclass=1;
break;
case "廚衛(wèi)空間":
$sclass=2;
break;
case "家具物語(yǔ)":
$sclass=3;
break;
case "電器工程":
$sclass=4;
break;
case "居飾風(fēng)景":
$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 "<br/>";
$rs->Movenext(); //將記錄集指針下移
}
$rs->close();
?>
- asp php 清空access mysql mssql數(shù)據(jù)庫(kù)的代碼
- PHP數(shù)據(jù)庫(kù)鏈接類(PDO+Access)實(shí)例分享
- 三種php連接access數(shù)據(jù)庫(kù)方法
- php連接Access數(shù)據(jù)庫(kù)錯(cuò)誤及解決方法
- php access 數(shù)據(jù)連接與讀取保存編輯數(shù)據(jù)的實(shí)現(xiàn)代碼
- php實(shí)現(xiàn)可用于mysql,mssql,pg數(shù)據(jù)庫(kù)操作類
- PHP實(shí)現(xiàn)PDO的mysql數(shù)據(jù)庫(kù)操作類
- PHP操作MySQL事務(wù)實(shí)例
- PHP鏈接MySQL的常用擴(kuò)展函數(shù)
- php將access數(shù)據(jù)庫(kù)轉(zhuǎn)換到mysql數(shù)據(jù)庫(kù)的方法
相關(guān)文章
php使用scandir()函數(shù)掃描指定目錄下所有文件示例
這篇文章主要介紹了php使用scandir()函數(shù)掃描指定目錄下所有文件,涉及scandir()函數(shù)目錄掃描、文件遍歷及文件類型判斷等相關(guān)操作技巧,需要的朋友可以參考下2019-06-06php集成環(huán)境xampp中apache無(wú)法啟動(dòng)問(wèn)題解決方案
這篇文章主要介紹了php集成環(huán)境xampp中apache無(wú)法啟動(dòng)問(wèn)題解決方案,需要的朋友可以參考下2014-11-11file_get_contents("php://input", "r")實(shí)例介
本篇文章是對(duì)file_get_contents("php://input", "r")的實(shí)例進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07php加速緩存器opcache,apc,xcache,eAccelerator原理與配置方法實(shí)例分析
這篇文章主要介紹了php加速緩存器opcache,apc,xcache,eAccelerator原理與配置方法,結(jié)合實(shí)例形式分析了php加速緩存器opcache,apc,xcache,eAccelerator的基本功能、原理及擴(kuò)展配置相關(guān)操作技巧,需要的朋友可以參考下2020-03-03php監(jiān)測(cè)數(shù)據(jù)是否成功插入到Mysql數(shù)據(jù)庫(kù)的方法
在PHP中該怎么用代碼判斷數(shù)據(jù)是否成功插入到Mysql數(shù)據(jù)庫(kù)?這篇文章中給出了兩種解決的方法,大家可以根據(jù)需要選擇相對(duì)應(yīng)的方法,有需要的朋友們下面來(lái)跟著小編一起學(xué)習(xí)學(xué)習(xí)吧。2016-11-11生成靜態(tài)頁(yè)面的php函數(shù),php愛(ài)好者站推薦
生成靜態(tài)頁(yè)面的php函數(shù),php愛(ài)好者站推薦...2007-03-03php中url傳遞中文字符,特殊危險(xiǎn)字符的解決方法
本文章結(jié)合php中的urldecode,base64_encode函數(shù)然后再結(jié)合自己寫的替換函數(shù)來(lái)進(jìn)行安全傳遞url中文字符,特殊危險(xiǎn)字符,有需要的朋友可以參考一下2013-08-08php curl發(fā)送請(qǐng)求實(shí)例方法
在本篇文章里小編給大家整理的是關(guān)于php curl發(fā)送請(qǐng)求詳細(xì)教程以及相關(guān)知識(shí)點(diǎn),需要的朋友們可以學(xué)習(xí)下。2019-08-08