欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP读取ACCESS数据库实例代码

程序员文章站 2024-02-06 21:45:22
...
PHP读取ACCESS数据库实例代码

open($MM_Conn_STRING);//链接打开数据源

$query="select * from dm order by id asc";

$RS->open($query,$Conn,1,1);//执行语句,返回数据集

echo"共有:".$RS->RecordCount."条记录结果!
";//纪录数 for ($i=0;$ifields->Count;$i++) echo $RS->fields[$i]->Name." ";//遍历字段名 echo "
"; $connect = mysql_connect("192.168.0.51", "username", "password"); while(!$RS->EOF) { $query = "insert into smsGames.nanjing_toponym values('"; $query .= $RS->fields["id"]->value."', '"; $query .= $RS->fields["name"]->value."', '"; $query .= $RS->fields["symbol"]->value."', '"; $query .= str_replace("\r\n", "", $RS->fields["weizhi"]->value)."', '"; $query .= $RS->fields["way"]->value."', '"; $query .= $RS->fields["class"]->value."', '"; $query .= str_replace("\r\n", "", $RS->fields["history"]->value)."', '"; $query .= str_replace("\r\n", "", $RS->fields["addr"]->value)."')"; $result = mysql_query($query, $connect); if (!$result) print "Error:".mysql_error()."
Query:".$query."
"; else print $RS->fields["id"]->value." "; $RS->MoveNext(); $i++; } //释放资源 $Conn->Close(); $RS=NULL; $Conn =NULL; ?>