<?php

session_start();
$com="AS";
include("DMMYSQLG.php");
include("DMMYSQLG.php");
$resultado=[];  
	  $textBus=mysqli_real_escape_string($con,$_REQUEST['term']);
	  if(trim($textBus)!=''){
              $sq_invent=mysqli_query($con ,"SELECT DISTINCT(n_reg), pdesco 
                  FROM fcompas WHERE modulo='".$_SESSION['mod_sis']."' AND   pdesco like '$textBus%' or
               modulo='".$_SESSION['mod_sis']."' AND   n_reg like '$textBus%'  order by n_reg ");
              }
		 // @$sql = mysqli_query($con ,$sq_retrieve);
		  while(@$reg = mysqli_fetch_array($sq_invent)){
			
                      $row["label"]="(".$reg['n_reg'].")".$reg['pdesco'];
                       $row["descripcion"]=$reg['pdesco'];
                      $row["id"]=$reg['n_reg'];
                      $row["value"]=$reg['pdesco'];
                       
              $resultado[]=$row;  
		  }
	  
          
  echo json_encode($resultado);
          

//$q = mysqli_real_escape_string($con,$_GET["q"]);
//$limit= mysqli_real_escape_string($con,$_GET["limit"]);
//if($_GET['tipBus']=='d')
//	$sq_invent=mysqli_query($con ,"SELECT fcompas.pdesco,fcompas.n_reg,fcompas.cod_var FROM fcompas WHERE fcompas.modulo='".$_SESSION['mod_sis']."' AND   pdesco like '$q%' order by pdesco limit $limit");
//elseif($_GET['tipBus']=='c')
//		$sq_invent=mysqli_query($con ,"SELECT * FROM fcompas WHERE fcompas.modulo='".$_SESSION['mod_sis']."' AND   n_reg like '$q%' OR cod_var='$q' order by n_reg limit $limit");
//while($dt_invent=mysqli_fetch_array($sq_invent)){
//	echo "$dt_invent['pdesco']|$dt_invent['n_reg']\n";
//}
?>