Author Topic: Exact search  (Read 6565 times)

0 Members and 1 Guest are viewing this topic.

Offline Ofuuzo

  • Newbie
  • *
  • Posts: 29
    • View Profile
Exact search
« on: August 13, 2002, 03:22:37 PM »
Hi,
I added a function whichI call a quick search dropdown list:

<form>
<select name="quick_search">
<option value="">Quick search list</option>
<option value="../search.php?search_keywords=Jan Great ">Jan</option>
<option value="../search.php?search_keywords=Nicky Best"> Nicky</option>
.......

How can I make it to search exactly  for "Jan Great" and the result of the search will be only where "Jan Great" are found and not
occurrence of "Jan Peter", "John the Great", "Jan Great",...

Can you point me in which files I have to look or how I can do that in version 1.6. 1

Thanks.
Ofuuzo

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Exact search
« Reply #1 on: August 13, 2002, 03:31:28 PM »
There is no "Exact Phrase" search possible, sorry. But you do things like:

<option value="../search.php?search_keywords=Jan+%2BGreat">Jan</option>

This will find images with Jan AND Great. But this will also fin "Jan the Great".

+ = urlencoded Space
%2B = urlencoded +

Greets Jan
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Info

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: Exact search
« Reply #2 on: April 11, 2005, 11:24:24 AM »
This doesn't seem to work for me. If I enter the string "search.php?search_keywords=Jan+%2BGreat" I don't get the AND option but the OR option as result. Any idea how to change this to AND?

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: Exact search
« Reply #3 on: April 11, 2005, 06:53:04 PM »
Code: [Select]
<option value="../search.php?search_keywords=Jan+%2BGreat">Jan</option>
Actually there is another step needed  :wink:

Change that option value to this:
Code: [Select]
<option value="../search.php?search_keywords=Jan+Great&search_terms=all">Jan</option>You actually don't actually need the %2B

Open search.php and change this:
Code: [Select]
if (isset($HTTP_POST_VARS['search_terms'])) {
  $search_terms = (trim($HTTP_POST_VARS['search_terms']) == "all") ? 1 : 0;
To this:
Code: [Select]
if (isset($HTTP_POST_VARS['search_terms']) || isset($HTTP_GET_VARS['search_terms'])) {
  $search_terms = (trim($HTTP_POST_VARS['search_terms']) == "all" || trim($HTTP_GET_VARS['search_terms']) == "all") ? 1 : 0;

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Exact search
« Reply #4 on: April 12, 2005, 12:11:59 AM »
ok, am I missing something? if u want search so both keywords would match, just use AND in between them:
Jan+AND+Great
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: Exact search
« Reply #5 on: April 12, 2005, 01:56:15 AM »
Yeah that would work but if you wanted several words, it might be cumbersome:

search.php?search_keywords=my+AND+keywords+AND+another+AND+word+AND...

Either way works