将SQLite与PHP代码连接起来

I created a database with one table using SQLite. However, I am trying to get the data using PHP code but it doesn't work. Any help?

My code:

if ($pdo == null) {
    $pdo = new PDO('sqlite:/db/attendance');
}

$result = $myPDO->query("SELECT * from Student");

enter image description here

When you ask PHP to open /db/attendance you are specifying an absolute path: a file called attendance in a directory called db in the root of your filesystem.

You probably want to specify either a relative path, or an absolute path that is built from your script's location.

Try leaving the leading / off of the front of your path:

$pdo = new PDO('sqlite:db/attendance');

or, even better, building it from the __DIR__ magic constant:

$pdo = new PDO('sqlite:' . __DIR__ . '/db/attendance');