Jump to content

Recommended Posts

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;
}

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.

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!!

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.

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";

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.