Home > php教程 > php手册 > body text

php access 数据连接与读取保存编辑数据

WBOY
Release: 2016-06-13 11:23:45
Original
1075 people have browsed it

php教程 access 数据连接与读取保存数据解析

$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("www.bkjia.com/db.mdb");
//与access连接要用到com接口了。
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet");
//数据查询并显示出来
$rs->Open("select * from szd_t",$conn,1,1);
while(! $rs->eof) {
 $f = $rs->Fields(1);
 echo $f->value;
 $rs->MoveNext();
}

//下面来看一下php access数据库教程保存

$sql ="insert into szd_t(title)values('www.bkjia.com')";

$rs->Open( $sql );
echo '保存成功';

//php access数据库编辑

$sql ="Update szd_t set title="php100.com" where id=".$_GET['id'];

$rs->Open( $sql );
echo '编辑成功';

//删除数据

$sql ="delete from szd_t where id=".$_GET['id'];

//本文章原创于www.bkjia.com,转载注明出处


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template