首页  >  文章  >  后端开发  >  php sqlite_fetch_array函数的二个例子

php sqlite_fetch_array函数的二个例子

WBOY
WBOY原创
2016-07-25 08:57:521015浏览
  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. ?>
复制代码


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn