Home >php教程 >php手册 >璇诲彇ACCESS鏁版嵁鍒癕YSQL鐨凱HP浠g爜 - PHP鍏ラ棬

璇诲彇ACCESS鏁版嵁鍒癕YSQL鐨凱HP浠g爜 - PHP鍏ラ棬

WBOY
WBOYOriginal
2016-05-26 15:22:001929browse

涓嬮潰瀹炰緥姣旇緝绠€鍗?灏辨槸鍏堝埄鐢╟om鎺ュ彛璇诲彇access鏁版嵁搴?鎶婃暟鎹鍙栧悗鍐嶈繛鎺ysql鏁欑▼鏁版嵁搴?鎶婂搴旂殑瀛楁insert鍒癿ysql瀵瑰簲鐨勮〃涓庡瓧娈靛氨瀹炵幇浜?璇诲彇ACCESS鏁版嵁鍒癕YSQL鐨凱HP浠g爜濡備笅:

<?php 
	header(&#39;ontent-Type:text/html;charset=GB2312&#39;);//閬垮厤杈撳嚭涔辩爜 
	$dbhost     ="localhost"; 
	$dbuser     ="root"; 
	$dbpassword = "123456"; 
	$dbname     = "139miaosha"; 
	mysql_connect($dbhost,$dbuser,$dbpassword) or die("error!"); 
	mysql_query("set names &#39;gbk&#39;"); 
	mysql_select_db(&#39;139miaosha&#39;); 
	 
	 
	 $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"); 
	//寮€婧愪唬鐮乸hprm.com 
	 $rs->Open("select * from News where bigclassname=&#39;瑁呬慨璇惧爞&#39;",$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(&#39;".$rs->Fields[1]."&#39;,&#39;".$rs->Fields[2]."&#39;,1,".$sclass.",&#39;&#39;,&#39;".$spic."&#39;,&#39;".$user."&#39;,".$hits.",1)"; 
	     $result=mysql _query($sql); 
	     //echo  $rs->Fields[1]; 
	     //echo "<br/>"; 
	     $rs->Movenext(); //灏嗚褰曢泦鎸囬拡涓嬬Щ 
	 } 
	 $rs->close(); 
	

鏈枃鍦板潃锛?a target="_self" data-cid="10425" href="">

杞浇闅忔剰锛屼絾璇烽檮涓婃枃绔犲湴鍧€:-)

Statement:
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