■実行結果

1:Taro
2:Hanako


■テーブル定義

kokaki@skynew:~/www/html$ sqlite3 phpsqlite3test.db
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
sqlite> create table students(id int,name varchar(20));
sqlite> insert into students (id,name) values (1,'Taro'),(2,'Hanako');
sqlite> .schema students
CREATE TABLE students(id int,name varchar(20));
sqlite> .q


■テーブル内容

kokaki@skynew:~/www/html$ sqlite3 phpsqlite3test.db
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
sqlite> select * from students;
1|Taro
2|Hanako
sqlite> .q


■phpコード

<?php
    $db = new SQLite3('phpsqlite3test.db');
    $query = "SELECT id, name FROM students;";
    $result = $db->query($query);
    while ($row = $result->fetchArray()) {
        echo($row['id'] . ':' . $row['name']) . '<br>';
    }
?>