Jump to content

block out certain words from search


iscnetwork

Recommended Posts

Hello to all and thanks in advance for your assistance.  I am never going to be a good programmer.  Butch


I have 2 sets of code that I cannot put together and make work.  I am trying to have a search of a concordance. But I want to keep out stupid words like they, them, etc. that just take up horsepower.  I included a 'space' figuring that would take out multiple word searches.  I need one other thing which I had no clue about; stop all searches for words under 3 characters long or contain numbers.


 

<?php

 

$forbiden_word=" "||"them"||"they";

 

# if $forbiden_word matches the submited word

if($_POST['keysearch']==$forbiden_word)

{

$message='The word: '.$forbiden_word.' is not allowed.';

}

else

 

?>

 

<?php echo $message; ?>

 

<form method="post" action="result.php" name="keysearch" onSubmit="<?php echo $_SERVER['REQUEST_URI']; ?>" />

   

<h3>Enter single word at least 3 characters long.</h3>

 

<input type="text" name="search" value="" size="40"  /><br />

 

<input type="submit" value="Display Results" />

 

</form>

 

 

Link to comment
Share on other sites

If you're using MySQL's MATCH...AGAINST syntax (which was designed exactly for this kind of search) you can put words into MySQL's stopword list and have the database exclude them automatically.

 

Barand and I are suggesting the same thing.  MATCH...AGAINST is applied against columns with a FULLTEXT index.  Google for either.

Link to comment
Share on other sites

You just describe items way above my PHP levels. Also the rest of the program is very tight so I don't know how half of it works.  The receivers are even less knowledgeable than myself.  If this helps here is what I am trying to tune...

 

http://www.christianlibrary.org/bibles/bs/advancedsearch.php

 

I have found people putting in 'a' just for the stupidity of it.

 

thanks,

butch

Link to comment
Share on other sites

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.