wario Posted July 9, 2005 Share Posted July 9, 2005 OK, basically when I try to use the search function on the site I'm developing, many of the products won't show up even though I search for DIRECT keywords (i.e. "Ink" is in the product name, but when I search for Ink, I don't get anything). Other times if I search for "Case" amoung the results a Digital Camera will show up :blink: This is really frustrating, can anyone tell me how the search function works, or just how to get the products listed on the search page please... btw the site URL is: http://newtechnet.hopto.org/ntnshop/catalog : This is hosted locally, so if you can't access the page it's because my comp is turned off :P Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 Still looking for some help... just check out the site and search for "Ink" and you'll see what I mean...please help me....I have tried for many hours, but can't figure out why sometimes it works and other times it doesnt...is there a way to tell it NOT to search product discriptions and only product names or something? Link to comment Share on other sites More sharing options...
boxtel Posted July 10, 2005 Share Posted July 10, 2005 Still looking for some help... just check out the site and search for "Ink" and you'll see what I mean...please help me....I have tried for many hours, but can't figure out why sometimes it works and other times it doesnt...is there a way to tell it NOT to search product discriptions and only product names or something? <{POST_SNAPBACK}> I get 6 products on "ink" Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted July 10, 2005 Share Posted July 10, 2005 I get 6 products on "ink" <{POST_SNAPBACK}> and "case" is in the description of that digital camera. Treasurer MFC Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 yes you get 2 Ink products, which is fine, but you also get CD-Drives and DVD-Drives...and I think it's because there is the word "ink" in those descriptions... Yes that's the problem is there a way of making it so only the product names are searched, and not the descriptions? Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted July 10, 2005 Share Posted July 10, 2005 Still looking for some help... just check out the site and search for "Ink" and you'll see what I mean...please help me....I have tried for many hours, but can't figure out why sometimes it works and other times it doesnt...is there a way to tell it NOT to search product discriptions and only product names or something? <{POST_SNAPBACK}> I searched for Ink, and got 6 results ... :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ... Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 OK yes, I worked on the search since my first post...please read my 2nd/3rd posts - I'll edit my first post OK looks like you can't edit any post except your last. Bascially my problem now is that along with the products they searched for, you also get products that have nothing to do with the searched item. - so searching for "Ink" will also get you cd-drives/dvd drvies. Searching for "case" will get you cases AND power supplies AND and a digital camera... Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted July 10, 2005 Share Posted July 10, 2005 yes you get 2 Ink products, which is fine, but you also get CD-Drives and DVD-Drives...and I think it's because there is the word "ink" in those descriptions... <{POST_SNAPBACK}> yes, in advanced_searc_results.php the code also looks in description, manufacturer and category name. If you only want to search the product titles, you might not do your customers a favor, as they can further limit their searches ... but if you still want it, post yur search file and I'l tell you where to modify it. :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ... Link to comment Share on other sites More sharing options...
boxtel Posted July 10, 2005 Share Posted July 10, 2005 OK yes, I worked on the search since my first post...please read my 2nd/3rd posts - I'll edit my first post OK looks like you can't edit any post except your last. Bascially my problem now is that along with the products they searched for, you also get products that have nothing to do with the searched item. - so searching for "Ink" will also get you cd-drives/dvd drvies. Searching for "case" will get you cases AND power supplies AND and a digital camera... <{POST_SNAPBACK}> Yes, normally with "quick search", the one in the box, it does not search in the description. That you can turn on/off on the advanced search page. But I would not turn it off as it will limit your results dramatically as Monika stated. Instead I would offer additional conditions like searching on product types or alter the search so it only recognizes whole words. Treasurer MFC Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 Super, I'll post it...but which search file do you mean - the search.php in includes/boxes? if so, here it is, I think I know the modification that needs to be made, but I'll let someone who knows more about this stuff (i.e. you) do it. ^_^ I'm using a contribution for the search, but I don't think it's a big difference...is it? <?php /* $Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License Modified by Snowbird */ ?> <!-- search //--> <tr> <td> <?php function tep_draw_colored_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { $field = '<select name="' . tep_output_string($name) . '"'; if (tep_not_null($parameters)) $field .= ' ' . $parameters; $field .= '>'; if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); for ($i=0, $n=sizeof($values); $i<$n; $i++) { $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"'; if ($values[$i]['text'][12] == '&') { //is it 2nd sub category item? $field .= ' style="background-color: #f1f9fe; color: #100010; font-weight: normal; font-size: 8px;"'; } else if ($values[$i]['text'][6] == '&') { //is it sub category item? $field .= ' style="background-color: #f1f9fe; color: #000000; font-weight: bold; font-size: 9px;"'; } elseif ($values[$i]['text'][0] <> '&' && $default <> $values[$i]['id']) { //it is main category item? $field .= ' style="background-color: #ffcc33; color: black; font-weight: bold; font-size: 9px;"'; } if ($default == $values[$i]['id']) { $field .= ' SELECTED'; } $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>'; } $field .= '</select>'; if ($required == true) $field .= TEXT_FIELD_REQUIRED; return $field; } $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_SEARCH); $cat_array = array(); $cat_array[] = array('id' => '', 'text' => TEXT_ALL_CATEGORIES); $man_array = array(); $man_array[] = array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS); new infoBoxHeading($info_box_contents, true, false); $info_box_contents = array(); $info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), 'align' => 'left', 'text' => BOX_SEARCH_TEXT . '<br>' . tep_draw_hidden_field('search_in_description','1') . tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords','','size="10" maxlength="40" style="width: ' . (BOX_WIDTH-18) . 'px"') . ' ' . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH, 'align="absmiddle"') . '<br>' . tep_draw_colored_pull_down_menu('categories_id', tep_get_categories($cat_array), '', 'style="face=tahoma; font-size:9px; width: 100%"') . '<br>' . tep_draw_colored_pull_down_menu('manufacturers_id', tep_get_manufacturers($man_array), '', 'style="face=tahoma; font-size:9px; width: 100%"') . '<br>' . tep_hide_session_id() . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>') ; new infoBox($info_box_contents); ?> </td> </tr> <!-- search_eof //--> I hope this is the file you were talking about. Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 or alter the search so it only recognizes whole words. Yes I think this would also help quite a bit...how would I go about doing it? (I am still going to try turning off the search withing product description once Monika confirms which part to modify Link to comment Share on other sites More sharing options...
boxtel Posted July 10, 2005 Share Posted July 10, 2005 Super, I'll post it...but which search file do you mean - the search.php in includes/boxes? if so, here it is, I think I know the modification that needs to be made, but I'll let someone who knows more about this stuff (i.e. you) do it. ^_^ I'm using a contribution for the search, but I don't think it's a big difference...is it? <?php /* ?$Id: search.php,v 1.22 2003/02/10 22:31:05 hpdl Exp $ ?osCommerce, Open Source E-Commerce Solutions ?http://www.oscommerce.com ?Copyright (c) 2003 osCommerce ?Released under the GNU General Public License ?Modified by Snowbird */ ?> <!-- search //--> ? ? ? ? ?<tr> ? ? ? ? ? ?<td> <?php ?function tep_draw_colored_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { ? ?$field = '<select name="' . tep_output_string($name) . '"'; ? ?if (tep_not_null($parameters)) $field .= ' ' . $parameters; ? ?$field .= '>'; ? ?if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); ? ?for ($i=0, $n=sizeof($values); $i<$n; $i++) { ? ? ?$field .= '<option value="' . tep_output_string($values[$i]['id']) . '"'; ? ? ?if ($values[$i]['text'][12] == '&') { ?//is it 2nd sub category item? ? ? ? ? $field .= ' style="background-color: #f1f9fe; color: #100010; font-weight: normal; font-size: 8px;"'; ? ? ? ? } ? ? ? ? else if ($values[$i]['text'][6] == '&') { ?//is it sub category item? ? ? ? ? $field .= ' style="background-color: #f1f9fe; color: #000000; font-weight: bold; font-size: 9px;"'; ? ? ? ? } ? ? ? ? elseif ($values[$i]['text'][0] <> '&' && $default <> $values[$i]['id']) { ?//it is main category item? ? ? ? ? $field .= ' style="background-color: #ffcc33; color: black; font-weight: bold; font-size: 9px;"'; ? ? ? ? } ? ? ?if ($default == $values[$i]['id']) { $field .= ' SELECTED'; } ? ? ?$field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>'; ? ?} ? ?$field .= '</select>'; ? ?if ($required == true) $field .= TEXT_FIELD_REQUIRED; ? ?return $field; ?} ?$info_box_contents = array(); ?$info_box_contents[] = array('text' => BOX_HEADING_SEARCH); ?$cat_array = array(); ?$cat_array[] = array('id' => '', 'text' => TEXT_ALL_CATEGORIES); ?$man_array = array(); ?$man_array[] = array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS); ?new infoBoxHeading($info_box_contents, true, false); ?$info_box_contents = array(); ?$info_box_contents[] = array('form' => tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get'), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'align' => 'left', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => BOX_SEARCH_TEXT . '<br>' . ?tep_draw_hidden_field('search_in_description','1') . ?tep_draw_hidden_field('inc_subcat', '1', true) . tep_draw_input_field('keywords','','size="10" maxlength="40" style="width: ' . (BOX_WIDTH-18) . 'px"') . ' ' . tep_image_submit('button_quick_find.gif', IMAGE_BUTTON_SEARCH, 'align="absmiddle"') . '<br>' . ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_draw_colored_pull_down_menu('categories_id', tep_get_categories($cat_array), '', 'style="face=tahoma; font-size:9px; width: 100%"') . '<br>' . ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tep_draw_colored_pull_down_menu('manufacturers_id', tep_get_manufacturers($man_array), '', 'style="face=tahoma; font-size:9px; width: 100%"') . '<br>' . tep_hide_session_id() . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>'); ?new infoBox($info_box_contents); ?> ? ? ? ? ? ?</td> ? ? ? ? ?</tr> <!-- search_eof //--> I hope this is the file you were talking about. <{POST_SNAPBACK}> the only change you could make here is changing this : tep_draw_hidden_field('search_in_description','1') into this : tep_draw_hidden_field('search_in_description','0') which would result in the search NOT looking in the descriptions. Treasurer MFC Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 oh heh yah I copied pasted the search.php after making teh modification I thought needed to be made hehe. So that was the one right? OK, well yah as you guys warned it hurts the search...BUT if you put the proper product names..that should eliminate the downside of disabling the search within product description right? Also, about the recognizing only whole words.....:D any ideas how to do that ? Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted July 10, 2005 Share Posted July 10, 2005 the only change you could make here is changing this : tep_draw_hidden_field('search_in_description','1') into this : tep_draw_hidden_field('search_in_description','0') which would result in the search NOT looking in the descriptions. <{POST_SNAPBACK}> I need the advanced_search_results.php Do you REALLY want to only search in the title? Or are you willing to try the whole word thing first? Tell me what you need before I alter your file. :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ... Link to comment Share on other sites More sharing options...
boxtel Posted July 10, 2005 Share Posted July 10, 2005 oh heh yah I copied pasted the search.php after making teh modification I thought needed to be made hehe. So that was the one right? OK, well yah as you guys warned it hurts the search...BUT if you put the proper product names..that should eliminate the downside of disabling the search within product description right? Also, about the recognizing only whole words.....:D any ideas how to do that ? <{POST_SNAPBACK}> You would add spaces around the search keys like statements in the sql construction in advanced_search_result.php. That would make sure that it searches for " ink " and not "ink". Treasurer MFC Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 I need the advanced_search_results.php Do you REALLY want to only search in the title? Or are you willing to try the whole word thing first? Tell me what you need before I alter your file. <{POST_SNAPBACK}> I will try both for sure. I'm guessing both ways modify the same file. OK, if it's not toooooo much trouble would it be possible to show both ways? that would be great :D if it's an ultimatium (i.e. on or the other) I would choose the whole word approach first, but please if you have time can you show me both ways..I'm desperate :'( <?php /* $Id: advanced_search_result.php,v 1.72 2003/06/23 06:50:11 project3000 Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH); $error = false; if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) && (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) && (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) && (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) && (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) { $error = true; $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); } else { $dfrom = ''; $dto = ''; $pfrom = ''; $pto = ''; $keywords = ''; if (isset($HTTP_GET_VARS['dfrom'])) { $dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']); } if (isset($HTTP_GET_VARS['dto'])) { $dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']); } if (isset($HTTP_GET_VARS['pfrom'])) { $pfrom = $HTTP_GET_VARS['pfrom']; } if (isset($HTTP_GET_VARS['pto'])) { $pto = $HTTP_GET_VARS['pto']; } if (isset($HTTP_GET_VARS['keywords'])) { $keywords = $HTTP_GET_VARS['keywords']; } $date_check_error = false; if (tep_not_null($dfrom)) { if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) { $error = true; $date_check_error = true; $messageStack->add_session('search', ERROR_INVALID_FROM_DATE); } } if (tep_not_null($dto)) { if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) { $error = true; $date_check_error = true; $messageStack->add_session('search', ERROR_INVALID_TO_DATE); } } if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) { if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) { $error = true; $messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE); } } $price_check_error = false; if (tep_not_null($pfrom)) { if (!settype($pfrom, 'double')) { $error = true; $price_check_error = true; $messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM); } } if (tep_not_null($pto)) { if (!settype($pto, 'double')) { $error = true; $price_check_error = true; $messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM); } } if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) { if ($pfrom >= $pto) { $error = true; $messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM); } } if (tep_not_null($keywords)) { if (!tep_parse_search_string($keywords, $search_keywords)) { $error = true; $messageStack->add_session('search', ERROR_INVALID_KEYWORDS); } } } if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) { $error = true; $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); } if ($error == true) { tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false)); } $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH)); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE_2; ?></td> <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_2, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td> <?php // create column list $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } } $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price "; if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { $select_str .= ", SUM(tr.tax_rate) as tax_rate "; } $from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c"; if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { if (!tep_session_is_registered('customer_country_id')) { $customer_country_id = STORE_COUNTRY; $customer_zone_id = STORE_ZONE; } $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')"; } $where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id "; if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) { if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) { $subcategories_array = array(); tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']); $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'"; for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) { $where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'"; } $where_str .= ")"; } else { $where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'"; } } if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) { $where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"; } 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 .= " )"; } if (tep_not_null($dfrom)) { $where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom) . "'"; } if (tep_not_null($dto)) { $where_str .= " and p.products_date_added <= '" . tep_date_raw($dto) . "'"; } if (tep_not_null($pfrom)) { if ($currencies->is_set($currency)) { $rate = $currencies->get_value($currency); $pfrom = $pfrom / $rate; } } if (tep_not_null($pto)) { if (isset($rate)) { $pto = $pto / $rate; } } if (DISPLAY_PRICE_WITH_TAX == 'true') { if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")"; if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")"; } else { if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")"; if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")"; } if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { $where_str .= " group by p.products_id, tr.tax_priority"; } if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { if ($column_list[$i] == 'PRODUCT_LIST_NAME') { $HTTP_GET_VARS['sort'] = $i+1 . 'a'; $order_str = ' order by pd.products_name'; break; } } } else { $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); $sort_order = substr($HTTP_GET_VARS['sort'], 1); $order_str = ' order by '; switch ($column_list[$sort_col-1]) { case 'PRODUCT_LIST_MODEL': $order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_NAME': $order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : ""); break; case 'PRODUCT_LIST_MANUFACTURER': $order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_QUANTITY': $order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_IMAGE': $order_str .= "pd.products_name"; break; case 'PRODUCT_LIST_WEIGHT': $order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; case 'PRODUCT_LIST_PRICE': $order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; break; } } $listing_sql = $select_str . $from_str . $where_str . $order_str; require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?> </td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(array('sort', 'page')), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td> </tr> </table></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted July 10, 2005 Share Posted July 10, 2005 find this: 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; for doing the full word thing, change to this: 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; for only allowing the title, change to this: default: $keyword = tep_db_prepare_input($search_keywords[$i]); $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%'"; break; right now your search.php in boxes has the search by descrition, like Amanda told you. Alter that to your liking. for allowing title and description if checked, change to this: default: $keyword = tep_db_prepare_input($search_keywords[$i]); $where_str .= "(pd.products_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; for allowing title and description if checked, but both with full words only, change to this: default: $keyword = tep_db_prepare_input($search_keywords[$i]); $where_str .= "(pd.products_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; there is a few more variations ... let me know if you need more help. :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ... Link to comment Share on other sites More sharing options...
wario Posted July 10, 2005 Author Share Posted July 10, 2005 Great I will try out the mods, many thanks to both of you. I will let you know how it goes. Link to comment Share on other sites More sharing options...
boxtel Posted July 10, 2005 Share Posted July 10, 2005 I will try both for sure. I'm guessing both ways modify the same file. OK, if it's not toooooo much trouble would it be possible to show both ways? that would be great :D if it's an ultimatium (i.e. on or the other) I would choose the whole word approach first, but please if you have time can you show me both ways..I'm desperate :'( <?php /* ?$Id: advanced_search_result.php,v 1.72 2003/06/23 06:50:11 project3000 Exp $ ?osCommerce, Open Source E-Commerce Solutions ?http://www.oscommerce.com ?Copyright (c) 2003 osCommerce ?Released under the GNU General Public License */ ?require('includes/application_top.php'); ?require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH); ?$error = false; ?if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) && ? ? ? (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) && ? ? ? (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) && ? ? ? (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) && ? ? ? (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) { ? ?$error = true; ? ?$messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); ?} else { ? ?$dfrom = ''; ? ?$dto = ''; ? ?$pfrom = ''; ? ?$pto = ''; ? ?$keywords = ''; ? ?if (isset($HTTP_GET_VARS['dfrom'])) { ? ? ?$dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']); ? ?} ? ?if (isset($HTTP_GET_VARS['dto'])) { ? ? ?$dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']); ? ?} ? ?if (isset($HTTP_GET_VARS['pfrom'])) { ? ? ?$pfrom = $HTTP_GET_VARS['pfrom']; ? ?} ? ?if (isset($HTTP_GET_VARS['pto'])) { ? ? ?$pto = $HTTP_GET_VARS['pto']; ? ?} ? ?if (isset($HTTP_GET_VARS['keywords'])) { ? ? ?$keywords = $HTTP_GET_VARS['keywords']; ? ?} ? ?$date_check_error = false; ? ?if (tep_not_null($dfrom)) { ? ? ?if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) { ? ? ? ?$error = true; ? ? ? ?$date_check_error = true; ? ? ? ?$messageStack->add_session('search', ERROR_INVALID_FROM_DATE); ? ? ?} ? ?} ? ?if (tep_not_null($dto)) { ? ? ?if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) { ? ? ? ?$error = true; ? ? ? ?$date_check_error = true; ? ? ? ?$messageStack->add_session('search', ERROR_INVALID_TO_DATE); ? ? ?} ? ?} ? ?if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) { ? ? ?if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) { ? ? ? ?$error = true; ? ? ? ?$messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE); ? ? ?} ? ?} ? ?$price_check_error = false; ? ?if (tep_not_null($pfrom)) { ? ? ?if (!settype($pfrom, 'double')) { ? ? ? ?$error = true; ? ? ? ?$price_check_error = true; ? ? ? ?$messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM); ? ? ?} ? ?} ? ?if (tep_not_null($pto)) { ? ? ?if (!settype($pto, 'double')) { ? ? ? ?$error = true; ? ? ? ?$price_check_error = true; ? ? ? ?$messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM); ? ? ?} ? ?} ? ?if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) { ? ? ?if ($pfrom >= $pto) { ? ? ? ?$error = true; ? ? ? ?$messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM); ? ? ?} ? ?} ? ?if (tep_not_null($keywords)) { ? ? ?if (!tep_parse_search_string($keywords, $search_keywords)) { ? ? ? ?$error = true; ? ? ? ?$messageStack->add_session('search', ERROR_INVALID_KEYWORDS); ? ? ?} ? ?} ?} ?if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) { ? ?$error = true; ? ?$messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); ?} ?if ($error == true) { ? ?tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false)); ?} ?$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH)); ?$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> ?<tr> ? ?<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> ? ?</table></td> <!-- body_text //--> ? ?<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0"> ? ? ?<tr> ? ? ? ?<td><table border="0" width="100%" cellspacing="0" cellpadding="0"> ? ? ? ? ?<tr> ? ? ? ? ? ?<td class="pageHeading"><?php echo HEADING_TITLE_2; ?></td> ? ? ? ? ? ?<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_2, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> ? ? ? ? ?</tr> ? ? ? ?</table></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td> <?php // create column list ?$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, ? ? ? ? ? ? ? ? ? ? ? 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); ?asort($define_list); ?$column_list = array(); ?reset($define_list); ?while (list($key, $value) = each($define_list)) { ? ?if ($value > 0) $column_list[] = $key; ?} ?$select_column_list = ''; ?for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { ? ?switch ($column_list[$i]) { ? ? ?case 'PRODUCT_LIST_MODEL': ? ? ? ?$select_column_list .= 'p.products_model, '; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_MANUFACTURER': ? ? ? ?$select_column_list .= 'm.manufacturers_name, '; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_QUANTITY': ? ? ? ?$select_column_list .= 'p.products_quantity, '; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_IMAGE': ? ? ? ?$select_column_list .= 'p.products_image, '; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_WEIGHT': ? ? ? ?$select_column_list .= 'p.products_weight, '; ? ? ? ?break; ? ?} ?} ?$select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price "; ?if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { ? ?$select_str .= ", SUM(tr.tax_rate) as tax_rate "; ?} ?$from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c"; ?if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { ? ?if (!tep_session_is_registered('customer_country_id')) { ? ? ?$customer_country_id = STORE_COUNTRY; ? ? ?$customer_zone_id = STORE_ZONE; ? ?} ? ?$from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')"; ?} ?$where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id "; ?if (isset($HTTP_GET_VARS['categories_id']) && tep_not_null($HTTP_GET_VARS['categories_id'])) { ? ?if (isset($HTTP_GET_VARS['inc_subcat']) && ($HTTP_GET_VARS['inc_subcat'] == '1')) { ? ? ?$subcategories_array = array(); ? ? ?tep_get_subcategories($subcategories_array, $HTTP_GET_VARS['categories_id']); ? ? ?$where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and (p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'"; ? ? ?for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) { ? ? ? ?$where_str .= " or p2c.categories_id = '" . (int)$subcategories_array[$i] . "'"; ? ? ?} ? ? ?$where_str .= ")"; ? ?} else { ? ? ?$where_str .= " and p2c.products_id = p.products_id and p2c.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['categories_id'] . "'"; ? ?} ?} ?if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) { ? ?$where_str .= " and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"; ?} ?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 .= " )"; ?} ?if (tep_not_null($dfrom)) { ? ?$where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom) . "'"; ?} ?if (tep_not_null($dto)) { ? ?$where_str .= " and p.products_date_added <= '" . tep_date_raw($dto) . "'"; ?} ?if (tep_not_null($pfrom)) { ? ?if ($currencies->is_set($currency)) { ? ? ?$rate = $currencies->get_value($currency); ? ? ?$pfrom = $pfrom / $rate; ? ?} ?} ?if (tep_not_null($pto)) { ? ?if (isset($rate)) { ? ? ?$pto = $pto / $rate; ? ?} ?} ?if (DISPLAY_PRICE_WITH_TAX == 'true') { ? ?if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) >= " . (double)$pfrom . ")"; ? ?if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) * if(gz.geo_zone_id is null, 1, 1 + (tr.tax_rate / 100) ) <= " . (double)$pto . ")"; ?} else { ? ?if ($pfrom > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . (double)$pfrom . ")"; ? ?if ($pto > 0) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . (double)$pto . ")"; ?} ?if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) { ? ?$where_str .= " group by p.products_id, tr.tax_priority"; ?} ?if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) { ? ?for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { ? ? ?if ($column_list[$i] == 'PRODUCT_LIST_NAME') { ? ? ? ?$HTTP_GET_VARS['sort'] = $i+1 . 'a'; ? ? ? ?$order_str = ' order by pd.products_name'; ? ? ? ?break; ? ? ?} ? ?} ?} else { ? ?$sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1); ? ?$sort_order = substr($HTTP_GET_VARS['sort'], 1); ? ?$order_str = ' order by '; ? ?switch ($column_list[$sort_col-1]) { ? ? ?case 'PRODUCT_LIST_MODEL': ? ? ? ?$order_str .= "p.products_model " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_NAME': ? ? ? ?$order_str .= "pd.products_name " . ($sort_order == 'd' ? "desc" : ""); ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_MANUFACTURER': ? ? ? ?$order_str .= "m.manufacturers_name " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_QUANTITY': ? ? ? ?$order_str .= "p.products_quantity " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_IMAGE': ? ? ? ?$order_str .= "pd.products_name"; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_WEIGHT': ? ? ? ?$order_str .= "p.products_weight " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; ? ? ? ?break; ? ? ?case 'PRODUCT_LIST_PRICE': ? ? ? ?$order_str .= "final_price " . ($sort_order == 'd' ? "desc" : "") . ", pd.products_name"; ? ? ? ?break; ? ?} ?} ?$listing_sql = $select_str . $from_str . $where_str . $order_str; ?require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?> ? ? ? ?</td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> ? ? ?</tr> ? ? ?<tr> ? ? ? ?<td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(array('sort', 'page')), 'NONSSL', true, false) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td> ? ? ?</tr> ? ?</table></td> <!-- body_text_eof //--> ? ?<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> ? ?</table></td> ?</tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> <{POST_SNAPBACK}> in advanced_search_result.php you will find this : 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; change that to : 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; that means a space after the first % and a space before the last % per keyword. Treasurer MFC Link to comment Share on other sites More sharing options...
wario Posted July 13, 2005 Author Share Posted July 13, 2005 OK guys and gals, just an update on my situation - I used the last modification that Monika gave me and it improved the situation, but did not rectify it - If I search for "Ink" (for example) I will get 2 products, not all of them, and if I search for "case" I will get 1 or 2 computer cases (along with Power Supply, and a Camera), even though all of my computer cases have the word "Case" right in the title. Most surprisingly however, if you were to search for any manufacturing name, you would get NOTHING!! this part is very curious, try searching for "Canon", or "Lexmark" or "Epson" you get NO results...even though once again they are right in the title of teh product... My general feeling so far have been: :huh: <_< :unsure: :( :'( why could this be happening? and Monika you said there were some more variations - could you share them please... I also tried boxtel's code, and it results to almost the same thing. And throughout this time, I have kept tep_draw_hidden_field('search_in_description','1') Changing it zero (as you both said) just made things worse . help ...... ...... me... URL for the site I"m developing again for easy reference, in case you wanna see what I'm talking about: http://newtechnet.hopto.org/ntnshop/catalog and now the guy I'm making this for has caught on to the search malfunction, he's asking me about it, I just keep avoiding him, but I can't forever .... :( Link to comment Share on other sites More sharing options...
wario Posted July 13, 2005 Author Share Posted July 13, 2005 Sorry for the double post, but I can no longer edit my previous post. Just a thought: It seems as if the search ONLY searches in the product description - I have 5 cameras; 4 of them have product descriptions, yet no mention of "camera" in their names. The 5th camera has no description, yet has the word "camera" in it's product name. When I search for "camera" - guess what shows up? the 4 cameras that DON'T have the word camera in their product name...the 5th one doesn't show up even though it has the word in its title...suspicious? Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted July 13, 2005 Share Posted July 13, 2005 add a word that does not belong there to the l?ast search string (like add a second "where" right before the first. Upload, then sarch for Canon. The code will break and show you the select statement done ... Post that select statement along with a copy of the part you have changed in advanced_search_results.php Reupload the file corrected to what it was. Hopefully the select statemen will giveus an idea. :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ... Link to comment Share on other sites More sharing options...
wario Posted July 14, 2005 Author Share Posted July 14, 2005 OK good idea. So I broke the code, and it told me... 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'or pd.products_description like '% canon %') )' at line 1 select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ( or pd.products_description like '% canon %') ) and this is the modification that was done to advanced_search_result.php default: $keyword = tep_db_prepare_input($search_keywords[$i]); $wherewhere_str .= "(pd.products_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; hope that helps :unsure: Link to comment Share on other sites More sharing options...
♥Monika in Germany Posted July 14, 2005 Share Posted July 14, 2005 nope you added the second where to the variable name, that doesn't help. change code to this and repeat what I said, then change back after you copied the select for me: default: $keyword = tep_db_prepare_input($search_keywords[$i]); $where_str .= "(pd.products_name where 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; :-) Monika addicted to writing code ... can't get enough of databases either, LOL! my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum Interactive Media Award July 2007 ~ category E-Commerce my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ... Link to comment Share on other sites More sharing options...
boxtel Posted July 14, 2005 Share Posted July 14, 2005 nope you added the second where to the variable name, that doesn't help. change code to this and repeat what I said, then change back after you copied the select for me: default: $keyword = tep_db_prepare_input($search_keywords[$i]); $where_str .= "(pd.products_name where 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; <{POST_SNAPBACK}> I would simply add : echo $listing_sql; before : require(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); Treasurer MFC Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.