<?php
    include "include/config.php";
   
    if(isset($_REQUEST['getCountriesByLetters']) && isset($_REQUEST['letters'])){
        // keyword ; for search all codes
	$letters = $_REQUEST['letters'];
	$letters = preg_replace("/[^a-z0-9 \/\-.,]/si","",$letters);
        $LookupTable=$_REQUEST['LookupTable'];
	$LinkField = $_REQUEST['LinkField'];
	$DisplayField = $_REQUEST['DisplayField'];
        $Param = $_REQUEST['Param'];


	//$ssql="SELECT * FROM ({$LookupTable}  ) M where " . $LinkField . " like '".$letters."%'  $Param   limit 100";
        //$ssql="SELECT * FROM ({$LookupTable} {$Param}) M WHERE {$LinkField} LIKE '{$letters}%' OR {$DisplayField} LIKE '{$letters}%' Limit 100";
        $ssql="SELECT * FROM ({$LookupTable} {$Param}) M WHERE {$LinkField} LIKE '%{$letters}%' OR {$DisplayField} LIKE '%{$letters}%' ";
        #echo $ssql."###".$inf[0]."|";
        
	$res = mysql_query($ssql) or die("ERROR : {$ssql}");
   

	while($inf = mysql_fetch_array($res)){
		echo $inf[1]."###".$inf[0]."|";
	}


}
?>
