osCommerce and osCMax shopping cart software forums

Shopping Cart Software

osCommerce with teeth!

 
 

Search Problem

This is a discussion on Search Problem within the osCommerce 2.2 Modification Help forums, part of the osCommerce 2.2 Forums category; I was wondering if anyone could help me out with this problem. Here it is... When I search for an ...


Go Back   osCommerce and osCMax shopping cart software forums > osCommerce 2.2 Forums > osCommerce 2.2 Modification Help

Register FAQ Members List Calendar Mark Forums Read


Free community membership! Fast easy FREE membership
Closed Thread

 

LinkBack Thread Tools
  #1  
Old 09-26-2004, 06:12 PM
andyy15's Avatar
Member
 
Join Date: Aug 2004
Posts: 63
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0
andyy15
Default Search Problem

I was wondering if anyone could help me out with this problem. Here it is... When I search for an item say I enter "rings" the search turns up both "earrings" and "rings". I only want the search to turn up rings and not display earrings. Does anyone know how to fix this search algorithm problem? I have isolated it to this code:
Code:
 if (isset($search_keywords) && (sizeof($search_keywords) > 0)) {
   $where_str .= " and (";
   for ($i=0, $n=sizeof($search_keywords); $i<$n; $i++ ) {
     switch ($search_keywords[$i]) {
       case '(':
       case ')':
       case 'and':
       case 'or':
         $where_str .= " " . $search_keywords[$i] . " ";
         break;
       default:
         $keyword = tep_db_prepare_input($search_keywords[$i]);
         $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";
         if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
         $where_str .= ')';
         break;
     }
   }
   $where_str .= " )";
 }
Thanks,
Andrew
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
  #2  
Old 01-05-2007, 11:51 AM
Lurker
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0
robbiesmith79 is on a distinguished road
Wink Re: Search Problem

Just take out the %'s in the following lines:

$where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%' or m.manufacturers_name like '%" . tep_db_input($keyword) . "%'";
if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
$where_str .= ')';

to read:

$where_str .= "(pd.products_name like '" . tep_db_input($keyword) . "' or p.products_model like '" . tep_db_input($keyword) . "' or m.manufacturers_name like '" . tep_db_input($keyword) . "'";
if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '" . tep_db_input($keyword) . "'";
$where_str .= ')';

The % is a SQL wildcard character. If you searched for "rings" with the new script... you'll get "rings".

Robbie Smith
Azurite Design
Azurite Design - Sarasota and Bradenton Web Sites
O: 941-580-3452
C: 941-735-5592
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
The Following User Says Thank You to robbiesmith79 For This Useful Post:
michael_s (01-05-2007)
  #3  
Old 01-05-2007, 02:47 PM
Lurker
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 0
robbiesmith79 is on a distinguished road
Talking Re: Search Problem

My bad. the keyword LIKE is used in tandom with the %'s. If you take out the %'s, then the LIKE needs to be a '=' to get exact matches.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Advertisement
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
problem with admin panel search function taol osCMax v2 Features Discussion 0 12-13-2006 04:15 PM
How to have Quick Search also search in Descriptions ozstar osCommerce 2.2 Modification Help 1 12-09-2005 12:45 PM
Full text search in advanced search Anonymous osCMax v1.7 Discussion 0 04-15-2004 03:00 PM
Search Engine Submission Problem OyedeleG osCMax v1.7 Discussion 0 11-22-2003 06:45 PM
How to make search box also search descriptions marco6090 osCommerce 2.2 Modification Help 0 01-06-2003 05:31 AM


All times are GMT -8. The time now is 03:46 PM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
http://www.oscmax.com/forums/
Copyright 2008 osCMax