PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]); // ---- Inputs ---- $q = trim((string)($_GET['q'] ?? '')); $councilKeySel = trim((string)($_GET['council_key'] ?? '')); // table name like da_meandervalley $includeClosed = isset($_GET['include_closed']); $sort = (string)($_GET['sort'] ?? 'close'); // close|council|address|ref // ---- Discover da_* tables ---- $allTables = []; $st = $pdo->query("SHOW TABLES"); while ($row = $st->fetch(PDO::FETCH_NUM)) { $t = $row[0]; if (strpos($t, 'da_') === 0) $allTables[] = $t; } // Exclude tables you don't want to UNION $exclude = ['geo_cache', 'da_plandata', 'da_plan_data', 'da_dorset_stages']; // add more here if needed $allTables = array_values(array_filter($allTables, fn($t) => !in_array($t, $exclude, true))); if (!$allTables) { http_response_code(200); echo "
| Milestone | Stage | Opened | Target | Completed | Status |
|---|---|---|---|---|---|
| = h($sr['milestone'] ?? '') ?> | = h($sr['stage'] ?? '') ?> | = h(fmt_date($sr['opened'] ?? null)) ?> | = h(fmt_date($sr['target'] ?? null)) ?> | = h(fmt_date($sr['completed'] ?? null)) ?> | = h($sr['status'] ?? '') ?> |