 <?php

if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400'); // cache for 1 day
}

error_reporting(E_ERROR | E_PARSE);

$_SESSION['database'] = $_GET['database'];

include 'conn.php';
include 'funciones.php';

// CONSULTA

$sql = "SELECT * FROM " . $_GET['database'] . ".familia_mensajes";
$qur = $connection->query($sql);

while ($r = mysqli_fetch_assoc($qur)) {

    $jsonTempData = array();
    $jsonTempData['f_id'] = $r['f_id'];
    $jsonTempData['det_comanda_desc'] = utf8_encode($r['f_mensage']);
    $jsonData[] = $jsonTempData;
    $json->detalle_comanda = $jsonData;

}

if ($_SESSION['codigo'] == "99") {

    $json->datos = "false";

} else {
    $json->datos = "true";

}

print_r(json_encode($json));

$qur=null;
@mysqli_close($connection);
?>