Home > Backend Development > PHP Tutorial > PHP code to read ACCESS data to MYSQL_PHP tutorial

PHP code to read ACCESS data to MYSQL_PHP tutorial

WBOY
Release: 2016-07-21 15:29:54
Original
967 people have browsed it

Copy code The code is as follows:

header('ontent-Type: text/html;charset=GB2312 ');//Avoid garbled output
$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='Decoration Classroom'",$ conn,1,3);
while(!$rs->eof){
switch ($rs->Fields[4]){
case "Decoration Consultant":
$ sclass=1;
break;
case "Kitchen and Bathroom Space":
$sclass=2;
break;
case "Furniture Story":
$sclass=3;
break;
case "Electrical Engineering":
$sclass=4;
break;
case "Home Decoration and Landscape":
$sclass=5;
break;
case "material wide angle":
$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(); //Move the record set pointer down
}
$rs->close();
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323349.htmlTechArticleCopy the code as follows: ?php header('ontent-Type:text/html;charset=GB2312'); //Avoid garbled output $dbhost ="localhost"; $dbuser ="root"; $dbpassword = "123456"; $dbname = "139mia...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template