<?php

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

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

	$result = query("SELECT * FROM materia_prima inv 
                    WHERE inv.map_estatus = 'alta' 
                    AND (inv.map_clave LIKE '%$word%' OR inv.map_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;
    
?>