max_nt
|
Posted: 11/04/2002, 3:58 PM |
|
I want to implement a search for more words with the replacement of the space in the string with the percentual. The search must be executed for all the words in the keyword search and in any position. I'm looking for help to write this code in PHP. Thanks
|
|
|
Nicole
|
Posted: 11/10/2002, 11:45 PM |
|
Max,
In fact you should:
- catch the parameter string before Where clause is built (the event depends on application used);
- split it into separate words using e.g. PHP split() function and get the array of words;
- build Where in a loop adding the array items to Where clause using OR condition.
Here is sample code for CCS (it comes in grid form before Build Select event). In case you’re using CC put the code in the form Open event and use CC syntax to access field value, change Where and get the parameter.
global $form)name;
if (CCGetParam("paramname", ""))
{
$params = split(" ", CCGetParam("param_name", ""));
$form_name->ds->Where = "";
for ($i = 0; $i<=sizeof($params); $i++)
{
if (form_name->ds->Where == "")
$form_name->ds->Where = " task_name like '%".array_shift($params)."%'" ;
else
$form_name->ds->Where .=" OR task_name like '%".array_shift($params)."%'" ;
}
}
|
|
|
|