Trying to make a Edit As – Lookup Database Table as EDIT BOX with AJAX popup with a custom WHERE “somefield LIKE ‘%$value%’”
I want my notes table with a int(11) field called ContactID to lookup the Contact table and based on the users search query make a custom LIKE to find it. So they link on ID, display on say concat FirstName and Surname and in my where box i want to be able to enter one or many "FirstName LIKE '%$value%' OR Surname LIKE '%$value%' OR Email LIKE '%$value%' OR CompanyName LIKE '%$value%' OR Phone LIKE '%$value%'" as $value is the user searching in the field. I have tried $value, $_REQUEST[‘searchFor’]. how can I edit a file or get this to work in my project?
some screen grabs here if needed but i think what i wrote should be enough http://paigecomm.com.au/lookup-issue.pdf
Is there a better way that what I have done here as a hack to my files..
At the moment my only way to accomplish what I want is...
in my Edit lookup wizard i added the WHERE clause "FirstName LIKE '%%' OR Surname LIKE '%%' OR Email LIKE '%%' OR CompanyName LIKE '%%' OR Phone LIKE '%%' OR Mobile LIKE '%%' OR ID LIKE '%%' "
Then in my lookupsuggest.php file of my output project. Right before the $rs = db_query($LookupSQL,$conn); is executed on around line 160 i have put in some IF statements to check the incoming post requests to see where they originate from and then str_replace the $LookupSQL to find my %% i put in the lookup wizard and replace with the $_REQUEST[‘searchFor’] which is the active search in my lookup text field on my page..
if ($_REQUEST['searchField'] == "ContactID" && $_REQUEST['table'] == "notes"){
$LookupSQL = str_replace('%%','%'.$_REQUEST['searchFor'] .'%', $LookupSQL);
$LookupSQL = str_replace('AND','OR', $LookupSQL);
}else if ($_REQUEST['searchField'] == "LoanID" && $_REQUEST['table'] == "notes"){
$LookupSQL = str_replace('%%','%'.$_REQUEST['searchFor'] .'%', $LookupSQL);
$LookupSQL = str_replace('AND','OR', $LookupSQL);
}
Any other way that is nicer solution that me replace my outputed lookupsuggest.php file each time