einfache SQLite3 Datenbank

download
<?php
 
$db_name = "test.db";
$db_table = "namen";
 
$db = new SQLite3($db_name);
 
// Datenbank anlegen
 
$db-> exec("CREATE TABLE IF NOT EXISTS $db_table (
   id INTEGER PRIMARY KEY AUTOINCREMENT, 
   vorname TEXT,
   nachname TEXT
   )");
 
 
// Testdatensätze
/*   
$db->exec("INSERT INTO $db_table ( vorname, nachname) VALUES 
		('conny','henn' ),
		('simone','jennebach')
		");
 
*/
 
	$res = $db->query("select * from $db_table");
 
	echo "<table>";
		echo "<tr>";
		echo "<th>ID</th>";
		echo "<th>Vorname</th>";
		echo "<th>Nachname</th>";
		echo "</tr>";
 
		while ($dsatz = $res->fetchArray()) 
		{
			echo "<tr>";
			echo "<td>".$dsatz["id"]."</td>";
			echo "<td>".$dsatz["vorname"]."</td>";
			echo "<td>".$dsatz["nachname"]."</td>";
			echo "</tr>";
		}
	echo "</table>";
?>