<?php 
$sql_busca='select 
			'.$_POST['idx'].'_codigo as codigo , 
			'.$_POST['idx'].'_descri as descri 
			from '.$_POST['idx'].'0 
			where 
			'.$_POST['idx'].'_codigo="'.$_POST['valor'].'"';


switch($_POST['idx'])
{
	case 'item':
	$sql_busca='select '.$_POST['idx'].'_codigo as codigo ,
				 '.$_POST['idx'].'_descri as descri , 
				 '.$_POST['idx'].'_ean as ean
					from '.$_POST['idx'].'0 
					where '.$_POST['idx'].'_codigo="'.$_POST['valor'].'" 
					or
					'.$_POST['idx'].'_ean="'.$_POST['valor'].'"';
	break;
}

echo $sql_busca;
//require('../'.$_POST['dat'].'/cfg/res.php');
require('../cfg/res.php');
mysql_query("SET NAMES 'utf8'");
$res_busca=mysql_query($sql_busca,$link_vcrx);
if(mysql_num_rows($res_busca)!=0)
{
	echo mysql_result($res_busca,0,'descri');
}
else
{
	echo '0';
}


?>