<?php

    require('../functions/conexion.php');

    $word = $_POST['word'];
    $i=0;

	$result = query("SELECT * FROM receta rec
                    WHERE rec.rec_estatus = 'alta' 
                    AND (rec.rec_clave LIKE '%$word%' OR rec.rec_nombre LIKE '%$word%');");
    
    while($row = mysqli_fetch_assoc($result)){
        $rowdata[$i] = $row;
        $i++;
    }

    if ($i>0){
        $res =  json_encode($rowdata,JSON_UNESCAPED_UNICODE);
    } else {
        $res =  '[{"id":"0"}]';	
    }
    echo $res;
    
?>