SERVER[''DOCUMENT_ROOT'']."/../library.db"; // open database file $handle = sqlite_open($db) or die("Could not open database"); // generate query string $query = "SELECT * FROM books"; // execute query $result = sqlite_query($handle, $query) or die("Error in query: ".sqlite_error_string(sqlite_last_error($handle))); // get the complete result set as a series of nested arrays $data = sqlite_fetch_all($result); // all done // close database file sqlite_close($handle); // check the array to see if it contains at least one record if (sizeof($data) > 0) { echo "<table cellpadding=10 border=1>"; // iterate over outer array (rows) // print values for each element of inner array (columns) foreach ($data as $row) { echo "<tr>"; echo "<td>".$row[0]."</td>"; echo "<td>".$row."</td>"; echo "<td>".$row."</td>"; echo "</tr>"; } echo "</table>"; } ?> </body> </html>