<?php
include 'db.php'; 

if ($cluster=='PRINCIPAL'){
        $sql = "SELECT idCLUSTER, NOMBRE FROM cluster"; 
        $result = $conn->query($sql);
        $json = [];
        while($row = $result->fetch_assoc()){
            $json[] = ['id'=>$row['NOMBRE'], 'text'=>$row['NOMBRE']];
        }
    }else{
        $sql = "SELECT idCLUSTER, NOMBRE FROM cluster 
                WHERE NOMBRE=$cluster"; 
        $result = $conn->query($sql);
        $json = [];
        while($row = $result->fetch_assoc()){
            $json[] = ['id'=>$row['NOMBRE'], 'text'=>$row['NOMBRE']];
        }
    }

    echo json_encode($json);
 ?>