復制代碼 代碼如下:
<?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 "裝修顧問":
$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 "<br/>";
$rs->Movenext(); //將記錄集指針下移
}
$rs->close();
?>