Home  >  Article  >  Backend Development  >  Two examples of php sqlite_fetch_array function

Two examples of php sqlite_fetch_array function

WBOY
WBOYOriginal
2016-07-25 08:57:52982browse
  1. /**
  2. * sqlite_fetch_array function gets the result set
  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. * The sqlite_fetch_array function outputs the result set
  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. ?>
复制代码


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn