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

php sqlite_fetch_array函数的二个例子

程序员文章站 2022-03-29 22:25:55
...
  1. /**
  2. * sqlite_fetch_array函数取结果集
  3. * by bbs.it-home.org
  4. */
  5. $sqldb = sqlite_open("mydatabase.db");
  6. $results = sqlite_query($sqldb, "SELECT * FROM employee");
  7. while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {
  8. echo "Name: $row[1] (Employee ID: ".$row['empid'].")
    ";
  9. }
  10. sqlite_close($sqldb);
  11. ?>
复制代码

例2,sqlite_fetch_array函数、list函数循环输出结果集

  1. /***
  2. * sqlite_fetch_array函数输出结果集
  3. * by bbs.it-home.org
  4. */
  5. $sqldb = sqlite_open("mydatabase.db");
  6. $results = sqlite_query($sqldb, "SELECT * FROM employee");
  7. while (list($empid, $name) = sqlite_fetch_array($results)) {
  8. echo "Name: $name (Employee ID: $empid)
    ";
  9. }
  10. sqlite_close($sqldb);
  11. ?>
复制代码