首頁  >  文章  >  後端開發  >  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