How to connect to a SQLite3 db with PHP How to connect to a SQLite3 db with PHP sqlite sqlite

How to connect to a SQLite3 db with PHP


<?php$db = new SQLite3('mysqlitedb.db');$results = $db->query('SELECT bar FROM foo');while ($row = $results->fetchArray()) {    var_dump($row);}?>

Taken from here: PHP: SQLite3::query - Manual


SQLite is enabled by default with PHP. You have to use the built-in class SQLite3 (you will find some examples on this page).


This is the best way I have found and I got it directly from the sqlite website:

<?php$db = new SQLite3('sqlite3db.db');$results = $db->query('select * from db');while ($row = $results->fetchArray()) {var_dump($row);}?>

Also if you're looking to include the php results into html like a table cell or something, go as such:

$results = $db->query('select * from db');?><?php  while ($row = $results2->fetchArray()) {?> <td><h4><?php echo $row['id'];?></h4></td><?php } ?>