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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| ||||
| ||||
| 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 .= " )";
}
Andrew |
| Sponsored Links | ||
| ||
| |
|
#2
| |||
| |||
| 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 |
| The Following User Says Thank You to robbiesmith79 For This Useful Post: | ||
michael_s (01-05-2007) | ||
|
#3
| |||
| |||
| 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. |
| Sponsored Links | ||
| ||
| Thread Tools | |
| |
| ||||
| 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 |