File "obtener_correos.php"

Full Path: C:/wamp64/www/INTERPRETE2/backend/obtener_correos.php
File size: 433 bytes
MIME-type: text/x-php
Charset: utf-8

<?php
include 'conexion.php';

$razon = $_GET['RAZON_SOCIAL'] ?? '';

$stmt = $conexion->prepare("SELECT EMAIL FROM registros WHERE RAZON_SOCIAL = ?");
$stmt->bind_param("s", $razon);
$stmt->execute();
$stmt->bind_result($correo_final);

$correos = [];

while ($stmt->fetch()) {
    if ($correo_final) {
        $correos[] = $correo_final;
    }
}

echo json_encode([
    'correos' => implode(',', $correos)
]);