Hi all,
I have tables as below:
Company:
id, company, product, contact, position, address, tel, fax, email, subdistrict, district, province, visits;
then I has Search function to search Company Name based on company field and was working good.
Next i want to add some features to query Company table based on field: company, product, position, subdistrict, district, and province with my own rule format, so people could able to query through search text field using my rules.
Here are the rules i want people would follow:
Search… company-name, subdistrict: xyz ENTER or
Search… product: wood, province: abcd ENTER or
Search… position: Manager ENTER or
etc,…
Please help me, any suggestion highly appreciated. Thanks.
Regards,
C
Hi all,
after thinking a little bit what i want, i come with this script.
+++++++++++++++++++++++++++++++++++++++++++++++++++
<?php
$strreservedword = array('company','product','contact','position','subdistrict','district','province',
'comp','prod','cont','posi','subd','dist','prov');
$wordcountstr = wordcount ($term);
switch($wordcountstr !== null)
{
case ($wordcountstr == 4):
$newword = explode(',', $term)
$newword_str0 = explode(':', $newword[0])
if (in_array($newword_str0[0], $strreservedword) !== false) {
$reserved_query0 = $newword_str0[0]; // output reserved word
$keyword_0 = $newword_str0[1]; // output reserved keyword
}
else {
$error = "type mismatch field-1";
}
$newword_str1 = explode(':', $newword[1])
if (in_array($newword_str1[0], $strreservedword) !== false) {
$reserved_query1 = $newword_str1[0]; // output reserved word
$keyword_1 = $newword_str1[1]; // output reserved keyword
}
else {
$error = "type mismatch field-2";
}
break;
case ($wordcountstr == 3):
$newword = explode(',', $term);
$keyword_0 = $newword[0]; // output reserved keyword
$newword_str = explode(':', $newword[1])
if (in_array($newword_str[0], $strreservedword) !== false) {
$reserved_query0 = $newword_str[0]; // output reserved word
$keyword_1 = $newword_str[1]; // output reserved keyword
}
else {
$error = "type mismatch field-1";
}
break;
case ($wordcountstr == 2):
$newword = explode(':', $term)
if (in_array($newword[0], $strreservedword) !== false) {
$reserved_query0 = $newword[0]; // output reserved word
$keyword = $newword[1]; // output reserved keyword
}
else {
$error = "type mismatch field-1";
}
break;
case ($wordcountstr == 1):
$keyword = $term;
break;
default:
$error = "type mismatch field-1";
break;
}
?>
+++++++++++++++++++++++++++++++++++++++++++++++++++
But its not short, please help me to make it simple and where i have to put it (model/controller)
Thanks.
Hi all,
I have tables as below:
Company:
id, company, product, contact, position, address, tel, fax, email, subdistrict, district, province, visits;
then I has Search function to search Company Name based on company field and was working good.
Next i want to add some features to query Company table based on field: company, product, position, subdistrict, district, and province with my own rule format, so people could able to query through search text field using my rules.
Here are the rules i want people would follow:
Search… company-name, subdistrict: xyz ENTER or
Search… product: wood, province: abcd ENTER or
Search… position: Manager ENTER or
etc,…
Please help me, any suggestion highly appreciated. Thanks.
Regards,
C