<?php
include 'db.php';

$data=array();
if(!isset($_GET['textobuscar'])){

$q=mysqli_query($conn, "SELECT `idD-EMPRESA` as idemp, `RSOCIAL-EMPRESA` as rsocial, `GIRO-EMPRESA_idGIRO-EMPRESA` as giro FROM `d-empresa`");
while ($row=mysqli_fetch_object($q)){
 $data[]=$row;
}
}else{
    $textobuscar = $_GET['textobuscar'];

   $q=mysqli_query($conn, "SELECT `idD-EMPRESA` as idemp, `RSOCIAL-EMPRESA` as rsocial, `GIRO-EMPRESA_idGIRO-EMPRESA` as giro FROM `d-empresa` WHERE (`RSOCIAL-EMPRESA` LIKE '%$textobuscar%')");
while ($row=mysqli_fetch_object($q)){
 $data[]=$row;
} 
}

echo json_encode($data);


?>

