HowdeeDoodee Posted June 19, 2007 Share Posted June 19, 2007 I need to add an "exact phrase" search option to search my db. Here is the code developed to search the db using other user selected options. At the bottom of the code you see "exact phrase" as a user option but I do not have a function or search code to refer to. The variable $SeeAlso is the variable sent to the php script from the html search form. $searchtype reflects the radio button options the user has selected. Thank you in advance for any replies. You help is valued. function presentedCode($SeeAlso,$searchtype) { global $fieldName1; if (!empty($SeeAlso)){ // ANY WORD OR ALL WORDS if (($searchtype[0]=="Any Word")||($searchtype[0]=="All Words")||($searchtype[0]=="A")){ // AND or OR if ($searchtype[0]=="Any Word"){$delm=" OR "; } else{$delm=" AND ";} // break the search string into individual words $list=explode(" ",$SeeAlso); // initiate this part of the query // whole or partial words? if (($searchtype[1]=="wholeword")||($searchtype[1]==1)){ $query.="(".wholeWordQuery($list[0]); }// end if else{ $query.="(`$fieldName1` LIKE '%".$list[0]."%'";}// end else // end init $in=1; // build the rest of this part of the query while($list[$in]!=null){ if ($searchtype[1]=="wholeword"){$query.="$delm".wholeWordQuery($list[$in]);} else{ $query.="$delm``$fieldName1` LIKE '%".$list[$in]."%'";}// end if $in+=1; }// end while // finalize this part of the query $query.=")"; }// end if (any word or all words) // EXACT PHRASE else if($searchtype[0]=="Exact Phrase"){ $query.=advancedQuery($SeeAlso); }// end EXACT PHRASE else } return $query; } Quote Link to comment https://forums.phpfreaks.com/topic/56290-solved-need-to-add-exact-phrase-option-to-search-db/ Share on other sites More sharing options...
teng84 Posted June 19, 2007 Share Posted June 19, 2007 can you show us the exact form. and sorry add exact phrase where?? Quote Link to comment https://forums.phpfreaks.com/topic/56290-solved-need-to-add-exact-phrase-option-to-search-db/#findComment-278058 Share on other sites More sharing options...
HowdeeDoodee Posted June 20, 2007 Author Share Posted June 20, 2007 Thank you teng84 for the response. In the code below, extracted from the code above, the function advancedQuery($SeeAlso) does not exist, even though the code makes a call to the function. I need a function that will search for an exact phrase. // EXACT PHRASE else if($searchtype[0]=="Exact Phrase"){ $query.=advancedQuery($SeeAlso); }// end EXACT PHRASE else } return $query; } The form can be seen at the following link. http://www.findthepower.net/CP/ABC2_Concord_NewTestFT.htm Thank you again for the response. Quote Link to comment https://forums.phpfreaks.com/topic/56290-solved-need-to-add-exact-phrase-option-to-search-db/#findComment-278080 Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 Sorry but I dont understand the code that you have ive tried to decode it but looks like im going to touch everything sorry to say this but the coding that you have really need allot of changes even the link that you gave also didnt work. it always give the message see also what about that and u also use htm instead of html thats sounds bad for using dom or javascript coz you arent using the satndard there that will cause you trouble for waht reason i dont want to elaborate. now if you want to get the exact query heres what I say: $query.="$delm``$fieldName1` LIKE '%".$list[$in]."%'"; cahnge to $query.="$delm``$fieldName1` ="put here the exact value""; if you want to change the function ask little by little an ill answer if im available will change your function as well as the structure that you have site deals with bible so im willing to help GOOD LUCK ASTIG!! Quote Link to comment https://forums.phpfreaks.com/topic/56290-solved-need-to-add-exact-phrase-option-to-search-db/#findComment-278105 Share on other sites More sharing options...
HowdeeDoodee Posted June 20, 2007 Author Share Posted June 20, 2007 Sorry but I dont understand the code that you have ive tried to decode it but looks like im going to touch everything sorry to say this but the coding that you have really need allot of changes even the link that you gave also didnt work. it always give the message see also what about that and u also use htm instead of html thats sounds bad for using dom or javascript coz you arent using the satndard there that will cause you trouble for waht reason i dont want to elaborate. I tried your sugggestion but it did not work. The link you said did not work does work, even you found it to work since you know what the site is about. Since you do not understand the php code, maybe we need to get other responses or need to start a new thread. Thank you for your time and input. Quote Link to comment https://forums.phpfreaks.com/topic/56290-solved-need-to-add-exact-phrase-option-to-search-db/#findComment-278414 Share on other sites More sharing options...
HowdeeDoodee Posted June 20, 2007 Author Share Posted June 20, 2007 Here is the answer. When the form submits the input box, in this case named 'SeeAlso', use a GET statement in the query to pick off the input 'SeeAlso'. $query = "SELECT * FROM `View2_Concord` WHERE `Topic` LIKE '%$_GET[seeAlso]%' OR `Subtopic` LIKE '%$_GET[seeAlso]%' ORDER BY `Lnum` ASC LIMIT $startrecord, $display"; Quote Link to comment https://forums.phpfreaks.com/topic/56290-solved-need-to-add-exact-phrase-option-to-search-db/#findComment-278460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.