<meta charset="utf-8">
<?php
class MyDB extends SQLite3{
function __construct(){
$this->open('test_db.db');
}
}
function listx($sql){
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
}
$res = $db->query($sql);
while($rs = $res->fetchArray(SQLITE3_ASSOC)){
?>
<tr>
<td><?=$rs['id']?></td>
<td><?=$rs['title']?></td>
</tr>
<?php
}
$db->close();
}
?>
<table border="1">
<?php
$sql = "SELECT * from test_tab order by id desc limit 5";
listx($sql);
?>
</table>