<?php
require __DIR__ . '/config.php'; // ✅ Correct file name

header('Content-Type: application/json');

// Create database connection
$conn = getDbConnection();

$query = "SELECT * FROM organizations ORDER BY created_at DESC";
$result = $conn->query($query);

$organizations = [];
while ($row = $result->fetch_assoc()) {
    $organizations[] = $row;
}

echo json_encode(["success" => true, "organizations" => $organizations]);

$conn->close();
?>
