php连接.dbf数据库

上一篇 / 下一篇  2007-01-26 15:50:45 / 个人分类:学习笔记

最近接了个做CET4成绩查询的小件,涉及对.dbf数据库的处理,写下备忘。

PHP连接DBF文件程序清单:

$data="datasource/cet.dbf";//dbase数据库的地址和文件名

$db=dbase_open($data,0) or die ("Can not connect to the *.dbf file!");

for ($i = 1; $i <= $record_numbers; $i++) {

   if($i>$record_numbers)break;

      $row = dbase_get_record_with_names($db, $i);

      if ($row['学号'])

  {

        $table=eregi("cet4",$row['语言级别'])?"cet4":"cet6";

         echo trim("UPDATE $table SET source='".$row['总分']."'WHERE examid='".$row['准考证']."' AND name='".$row['姓名']."' AND time='".$time."' AND lisense='".$row['身份证件号']."';\n<br />");//生成SQL语句

  }

 }

添加数据:

$db=dbase_open("book1.dbf",2);

$result=dbase_add_record($db,$content);//$content为一数组,包含所有要添加的字段值按字段顺序排列


TAG: 学习笔记

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar