<html>
<head>
</head>
<body>
<h2>SQLite Select</h2>

<!--PHP code--------------------------------------->
<?php

$dbFile = '/home/sultans/data/sqlite/sqlite.db'; 
$db     = new SQLite3($dbFile);
$table  = 'cars';

print "<p>  Database: $dbFile     \n";
print "<br> Table...: $table </p> \n";

$sql = "SELECT * from $table"; 

$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>