query($query2); while ($row2 = $result2->fetchArray()) { $string = $row2['fullname']; $parts = explode(" ", $string); if ($parts[0] == $_COOKIE["username"]){ $createEmail = $row2['email']; $createMobile = $row2['mobile']; $createdby = $row2['fullname']; } } $db2->close(); $dbFile4 = $parentDirectory . '/invoices/database/invoices.db'; if (!file_exists($dbFile4)) { $db = new SQLite3($dbFile4); if (!$db) { die("Failed to create the database file."); } // Create the 'projects' table $createQuery = "CREATE TABLE IF NOT EXISTS figures ( id INTEGER PRIMARY KEY AUTOINCREMENT, item TEXT, description TEXT, subtotal TEXT )"; $db->exec($createQuery); if (!$db->exec($createQuery)) { die("Failed to create the 'projects' table."); } $db->close(); } else { $db = new SQLite3($dbFile4); if (!$db) { die("Database connection failed: " . $db->lastErrorMsg()); } } // Function to fetch and display data function displayData($db) { $query = "SELECT id, item, description, subtotal FROM figures"; $result = $db->query($query); while ($row = $result->fetchArray(SQLITE3_ASSOC)) { $projectId = $row['id']; echo "