php sqlite_fetch_array函数的二个例子

发布时间:2020-08-04编辑:脚本学堂
本文分享下,php编程中有关sqlite_fetch_array函数的两个例子,有需要的朋友可以作个参考,掌握下sqlite_fetch_array函数的用法。

例1,sqlite_fetch_array函数示例。
 

复制代码 代码示例:
<?php
/**
* sqlite_fetch_array函数取结果集
* by www.jb200.com
*/
   $sqldb = sqlite_open("mydatabase.db");
   $results = sqlite_query($sqldb, "SELECT * FROM employee");
   while ($row = sqlite_fetch_array($results,SQLITE_BOTH)) {
          echo "Name: $row[1] (Employee ID: ".$row['empid'].")<br />";
   }
   sqlite_close($sqldb);
?>

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

复制代码 代码示例:
<?php
/***
* sqlite_fetch_array函数输出结果集
* by www.jb200.com
*/
   $sqldb = sqlite_open("mydatabase.db");
   $results = sqlite_query($sqldb, "SELECT * FROM employee");
   while (list($empid, $name) = sqlite_fetch_array($results)) {
          echo "Name: $name (Employee ID: $empid)<br />";
   }
   sqlite_close($sqldb);
?>