<html>
<head>
</head>
<body>
<h2>SQLite Display List of Tables</h2>
<!--PHP code--------------------------------------->
<?php
$dbFile = '/home/sultans/data/sqlite/sqlite.db';
$db = new SQLite3($dbFile);
print "<p> $dbFile </p> \n";
$sql = "SELECT name from sqlite_master
WHERE type='table' "; //table name could be sqlite_schema
$result = $db->query($sql);
print("<table border=1>");
$firstrow = true;
while ($row = $result->fetchArray(SQLITE3_ASSOC))
{
if ($firstrow)
{
print("\n<tr bgcolor=gray>");
foreach ($row as $name=>$value) //loop thru all column names/values
print('<th>'. $name .'</th>'); //print column name
}
$firstrow=false;
print("\n<tr>");
foreach ($row as $value) //loop thru all column values
print('<td>'. $value .'</td>'); //print column value
}
if ($firstrow) //if still first row
print('<tr><th>Query returned 0 rows</th></tr>');
print("\n</table>\n");
?>
<!------------------------------------------------>
</body>
</html>