0) { $floor = $sql->single( "SELECT * FROM floors WHERE id = ?", "i", [$floorId] ); } $isEdit = !empty($floor); $pageTitle = $isEdit ? "Stockwerk bearbeiten: " . htmlspecialchars($floor['name']) : "Neues Stockwerk"; $buildings = $sql->get("SELECT id, name FROM buildings ORDER BY name", "", []); $prefillBuildingId = (int)($_GET['building_id'] ?? 0); $selectedBuildingId = $floor['building_id'] ?? $prefillBuildingId; $existingSvgContent = ''; if (!empty($floor['svg_path'])) { $relativePath = ltrim((string)$floor['svg_path'], "/\\"); $absolutePath = __DIR__ . '/../../' . $relativePath; if (is_file($absolutePath) && is_readable($absolutePath)) { $existingSvgContent = file_get_contents($absolutePath) ?: ''; } } ?>