当前位置:Gxlcms > PHP教程 > phpsqlite_fetch_array函数的二个例子

phpsqlite_fetch_array函数的二个例子

时间:2021-07-01 10:21:17 帮助过:22人阅读

  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. ?>

人气教程排行