Web Hosting Forums

Page 1 of 2 1 2 LastLast
Results 1 to 15 of 17

This is a discussion on help me search this file (a newbie here) in the Hosting Talk & Chit-chat forum
the following file is the search file for my oscommerce site. however, i need to modify it for the following reasons: a)it does not like ...

  1. #1
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    help me search this file (a newbie here)

    the following file is the search file for my oscommerce site. however, i need to modify it for the following reasons:

    a)it does not like gaps. i.e. when a person types in FORDGT, nothing will come up even if you have a product called FORD GT.
    somewhere in the file is the code for this...

    b)if possible, it would be really neat to add a feature that makes it a little more intelligent. because i have a numberplate site, when someone types in A, it would be good if 4 came up, and the same for a few other letters.

    can anyone help with this?

    thankyou very much in advance, david

  2. #2
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    here is the main part of the file

    part one


    <link rel="stylesheet" type="text/css" href="stylesheet.css">
    <script language="javascript" src="includes/general.js"></script>
    <script language="javascript"><!--
    function check_form() {
    var error_message = "<?php echo JS_ERROR; ?>";
    var error_found = false;
    var error_field;
    var keywords = document.advanced_search.keywords.value;
    var dfrom = document.advanced_search.dfrom.value;
    var dto = document.advanced_search.dto.value;
    var pfrom = document.advanced_search.pfrom.value;
    var pto = document.advanced_search.pto.value;
    var pfrom_float;
    var pto_float;

    if ( ((keywords == '') || (keywords.length < 1)) && ((dfrom == '') || (dfrom == '<?php echo DOB_FORMAT_STRING; ?>') || (dfrom.length < 1)) && ((dto == '') || (dto == '<?php echo DOB_FORMAT_STRING; ?>') || (dto.length < 1)) && ((pfrom == '') || (pfrom.length < 1)) && ((pto == '') || (pto.length < 1)) ) {
    error_message = error_message + "<?php echo JS_AT_LEAST_ONE_INPUT; ?>";
    error_field = document.advanced_search.keywords;
    error_found = true;
    }

    if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>')) {
    if (!IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) {
    error_message = error_message + "<?php echo JS_INVALID_FROM_DATE; ?>";
    error_field = document.advanced_search.dfrom;
    error_found = true;
    }
    }

    if ((dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>')) {
    if (!IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>')) {
    error_message = error_message + "<?php echo JS_INVALID_TO_DATE; ?>";
    error_field = document.advanced_search.dto;
    error_found = true;
    }
    }

    if ((dfrom.length > 0) && (dfrom != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dfrom, '<?php echo DOB_FORMAT_STRING; ?>')) && (dto.length > 0) && (dto != '<?php echo DOB_FORMAT_STRING; ?>') && (IsValidDate(dto, '<?php echo DOB_FORMAT_STRING; ?>'))) {
    if (!CheckDateRange(document.advanced_searc h.dfrom, document.advanced_search.dto)) {
    error_message = error_message + "<?php echo JS_TO_DATE_LESS_THAN_FROM_DATE; ?>";
    error_field = document.advanced_search.dto;
    error_found = true;
    }
    }

    if (pfrom.length > 0) {
    pfrom_float = parseFloat(pfrom);
    if (isNaN(pfrom_float)) {
    error_message = error_message + "<?php echo JS_PRICE_FROM_MUST_BE_NUM; ?>";
    error_field = document.advanced_search.pfrom;
    error_found = true;
    }
    } else {
    pfrom_float = 0;
    }

    if (pto.length > 0) {
    pto_float = parseFloat(pto);
    if (isNaN(pto_float)) {
    error_message = error_message + "<?php echo JS_PRICE_TO_MUST_BE_NUM; ?>";
    error_field = document.advanced_search.pto;
    error_found = true;
    }
    } else {
    pto_float = 0;
    }

    if ( (pfrom.length > 0) && (pto.length > 0) ) {
    if ( (!isNaN(pfrom_float)) && (!isNaN(pto_float)) && (pto_float < pfrom_float) ) {
    error_message = error_message + "<?php echo JS_PRICE_TO_LESS_THAN_PRICE_FROM; ?>";
    error_field = document.advanced_search.pto;
    error_found = true;
    }
    }

    if (error_found == true) {
    alert(error_message);
    error_field.focus();
    return false;
    } else {
    RemoveFormatString(document.advanced_sea rch.dfrom, "<?php echo DOB_FORMAT_STRING; ?>");
    RemoveFormatString(document.advanced_sea rch.dto, "<?php echo DOB_FORMAT_STRING; ?>");
    return true;
    }
    }

  3. #3
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    re (2)

    p2

    function popupWindow(url) {
    window.open(url,'popupWindow','toolbar=n o,location=no,directories=no,status=no,m enubar=no,scrollbars=yes,resizable=yes,c opyhistory=no,width=450,height=280,scree nX=150,screenY=150,top=150,left=150')
    }
    //--></script>
    </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 //-->

    <?php
    $info_box_contents = array();
    $info_box_contents[] = array('text' => HEADING_SEARCH_CRITERIA);

    new infoBoxHeading($info_box_contents, true, true);

    $info_box_contents = array();
    $info_box_contents[] = array('text' => tep_draw_input_field('keywords', '', 'style="width: 100%"'));
    $info_box_contents[] = array('align' => 'right', 'text' => tep_draw_checkbox_field('search_in_descr iption', '1') . ' ' . TEXT_SEARCH_IN_DESCRIPTION);

    new infoBox($info_box_contents);

    <?php
    $options_box = '<table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n" .
    ' <tr>' . "\n" .
    ' <td class="fieldKey">' . ENTRY_CATEGORIES . '</td>' . "\n" .
    ' <td class="fieldValue">' . tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))) . '<br></td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td class="fieldKey">&nbsp;</td>' . "\n" .
    ' <td class="smallText">' . tep_draw_checkbox_field('inc_subcat', '1', true) . ' ' . ENTRY_INCLUDE_SUBCATEGORIES . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td colspan="2">' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td class="fieldKey">' . ENTRY_MANUFACTURERS . '</td>' . "\n" .
    ' <td class="fieldValue">' . tep_draw_pull_down_menu('manufacturers_i d', tep_get_manufacturers(array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)))) . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td colspan="2">' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td class="fieldKey">' . ENTRY_PRICE_FROM . '</td>' . "\n" .
    ' <td class="fieldValue">' . tep_draw_input_field('pfrom') . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td class="fieldKey">' . ENTRY_PRICE_TO . '</td>' . "\n" .
    ' <td class="fieldValue">' . tep_draw_input_field('pto') . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td colspan="2">' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td class="fieldKey">' . ENTRY_DATE_FROM . '</td>' . "\n" .
    ' <td class="fieldValue">' . tep_draw_input_field('dfrom', DOB_FORMAT_STRING, 'onFocus="RemoveFormatString(this, \'' . DOB_FORMAT_STRING . '\')"') . '</td>' . "\n" .
    ' </tr>' . "\n" .
    ' <tr>' . "\n" .
    ' <td class="fieldKey">' . ENTRY_DATE_TO . '</td>' . "\n" .
    ' <td class="fieldValue">' . tep_draw_input_field('dto', DOB_FORMAT_STRING, 'onFocus="RemoveFormatString(this, \'' . DOB_FORMAT_STRING . '\')"') . '</td>' . "\n" .
    ' </tr>' . "\n" .
    '</table>';

  4. #4
    Rogue Developer
    Join Date
    Oct 2002
    Posts
    191

    Re: help me search this file (a newbie here)

    Originally posted by davidstummer
    a)it does not like gaps. i.e. when a person types in FORDGT, nothing will come up even if you have a product called FORD GT.
    somewhere in the file is the code for this...
    There are two options I can see, but on very quick inspection of the two files you listed neither of them appears to contain the code to be modified. First, you can compare on, say, the first two characters of the strings. So FORDGT would find FORD GT, but it would also find FORD EXPLORER.

    The second but more run-time-intensive option is to use the REPLACE function. So changing the sql statement to use REPLACE(car_field, " ","") instead of just car_field would do the trick, but you'd also have to eliminate the spaces from the search field as well, otherwise FORD GT would no longer find anything.

    The second option can be modified to include a field duplicating data in car_field only lacking spaces. The maintenance cost may increase though.

    b)if possible, it would be really neat to add a feature that makes it a little more intelligent. because i have a numberplate site, when someone types in A, it would be good if 4 came up, and the same for a few other letters.
    Could you elaborate on this point? Do you mean when a user types 'a' in a text field, the character '4' is appended to the text field?

  5. #5
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    5,884
    What I think he's getting at is that he wants a query, if you search for ABC also returns results that include 4BC. He mentions it is a license plate database and people commonly substitute numbers for letters if the phrase they want isn't available. In order to do this you would first have to map out the number to letter associations and then write a script that incorporates all of the different possibilities. This could get very complicated very fast.

    For example, say you map the following number-letter associations:
    0=O, 1=I, 3=E, 4=A, 5=S, 6=G, 8=B

    Then you search for a plate, I'll use the one a friend of mine has: "PARDONME" (he's hard of hearing and says "Pardon me?" a lot). Based on those combinations, you'd have to search for (I'm using lowercase to make it easier to tell numbers from letters):

    pardonme, p4rdonme, pard0nme, pardonm3, p4rd0nme, p4rdonm3, pard0nm3, and p4rd0nm3

    There are eight different possibilities from that one simple phrase. In order to do this, you would have to write a fairly complex procedure to come up with all of the possibilities and then you'd have to execute the search for each of those. This would be quite time consuming to run.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  6. #6
    Rogue Developer
    Join Date
    Oct 2002
    Posts
    191
    Ah, I see now. Well it actually wouldn't be all that bad... I imagine the number of letters in the string to match wouldn't be that high, and the number of possible substitutions would probably be pretty limited as well. So what I'd suggest doing is reading up on REGEXP. What it does is allow you to search a text field based on matching a regular expression. So if you had the records:

    -fear
    -phear
    -ph34r
    -ph3ar
    -f3ar
    -scared

    the select statement: SELECT plate FROM platetable WHERE plate REGEXP '[f"ph"][e3][a4]r'; would find the records:

    -fear
    -phear
    -ph34r
    -ph3ar
    -f3ar

    All you need to do is write a function to make that regular expression from the given string, and with the size constraints placed on the string it won't be too taxing on system resources. In fact you can use str_replaces to create it, so you won't even have to look letter by letter. For example, this should do the F->PH mapping:

    $str = str_replace ('f','[f"ph"]', $str);

    Just be careful on the order of them. If, for example, you wanted F mapped to PH and P mapped to 9, make sure you do the P str_replace before the F str_replace.

  7. #7
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    wrong file oops

    sorry i have realised i posted the wrong file. the right file has a similar name. I have attached the right file for you to look at if you are interested.

  8. #8
    Rogue Developer
    Join Date
    Oct 2002
    Posts
    191
    Sorry... where's the file?

  9. #9
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    part1

    require('includes/application_top.php');

    require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH_RESULT);

    $error = 0; // reset error flag to false
    $errorno = 0;

    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']) && empty($HTTP_GET_VARS['pfrom'])) &&
    (isset($HTTP_GET_VARS['pto']) && empty($HTTP_GET_VARS['pto'])) ) {
    $errorno += 1;
    $error = 1;
    }

    $dfrom_to_check = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']);
    $dto_to_check = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']);

    if (strlen($dfrom_to_check) > 0) {
    if (!tep_checkdate($dfrom_to_check, DOB_FORMAT_STRING, $dfrom_array)) {
    $errorno += 10;
    $error = 1;
    }
    }

    if (strlen($dto_to_check) > 0) {
    if (!tep_checkdate($dto_to_check, DOB_FORMAT_STRING, $dto_array)) {
    $errorno += 100;
    $error = 1;
    }
    }

    if (strlen($dfrom_to_check) > 0 && !(($errorno & 10) == 10) && strlen($dto_to_check) > 0 && !(($errorno & 100) == 100)) {
    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])) {
    $errorno += 1000;
    $error = 1;
    }
    }

    if (strlen($HTTP_GET_VARS['pfrom']) > 0) {
    $pfrom_to_check = $HTTP_GET_VARS['pfrom'];
    if (!settype($pfrom_to_check, "double")) {
    $errorno += 10000;
    $error = 1;
    }
    }

    if (strlen($HTTP_GET_VARS['pto']) > 0) {
    $pto_to_check = $HTTP_GET_VARS['pto'];
    if (!settype($pto_to_check, "double")) {
    $errorno += 100000;
    $error = 1;
    }
    }

    if (strlen($HTTP_GET_VARS['pfrom']) > 0 && !(($errorno & 10000) == 10000) && strlen($HTTP_GET_VARS['pto']) > 0 && !(($errorno & 100000) == 100000)) {
    if ($pfrom_to_check > $pto_to_check) {
    $errorno += 1000000;
    $error = 1;
    }
    }

    if (strlen($HTTP_GET_VARS['keywords']) > 0) {
    if (!tep_parse_search_string(stripslashes($ HTTP_GET_VARS['keywords']), $search_keywords)) {
    $errorno += 10000000;
    $error = 1;
    }
    }

    if ($error == 1) {
    tep_redirect(tep_href_link(FILENAME_ADVA NCED_SEARCH, 'errorno=' . $errorno . '&' . tep_get_all_get_params(array('x', 'y'))));
    } else {
    $breadcrumb->add(NAVBAR_TITLE1, tep_href_link(FILENAME_ADVANCED_SEARCH)) ;
    $breadcrumb->add(NAVBAR_TITLE2, tep_href_link(FILENAME_ADVANCED_SEARCH_R ESULT, 'keywords=' . $HTTP_GET_VARS['keywords'] . '&search_in_description=' . $HTTP_GET_VARS['search_in_description'] . '&categories_id=' . $HTTP_GET_VARS['categories_id'] . '&inc_subcat=' . $HTTP_GET_VARS['inc_subcat'] . '&manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&pfrom=' . $HTTP_GET_VARS['pfrom'] . '&pto=' . $HTTP_GET_VARS['pto'] . '&dfrom=' . $HTTP_GET_VARS['dfrom'] . '&dto=' . $HTTP_GET_VARS['dto']));
    ?>

  10. #10
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    2

    ?>
    <!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; ?></td>
    <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE, 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($column, $value) = each($define_list)) {
    if ($value) $column_list[] = $column;
    }

    $select_column_list = '';

    for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    if ( ($column_list[$col] == 'PRODUCT_LIST_BUY_NOW') || ($column_list[$col] == 'PRODUCT_LIST_NAME') || ($column_list[$col] == 'PRODUCT_LIST_PRICE') ) {
    continue;
    }

    if (tep_not_null($select_column_list)) {
    $select_column_list .= ', ';
    }

    switch ($column_list[$col]) {
    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;

  11. #11
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    3

    }
    }

    if (tep_not_null($select_column_list)) {
    $select_column_list .= ', ';
    }

    $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') && ( (isset($HTTP_GET_VARS['pfrom']) && tep_not_null($HTTP_GET_VARS['pfrom'])) || (isset($HTTP_GET_VARS['pto']) && tep_not_null($HTTP_GET_VARS['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') && ( (isset($HTTP_GET_VARS['pfrom']) && tep_not_null($HTTP_GET_VARS['pfrom'])) || (isset($HTTP_GET_VARS['pto']) && tep_not_null($HTTP_GET_VARS['pto']))) ) {
    if (!tep_session_is_registered('customer_co untry_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 = '" . $customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . $customer_zone_id . "')";
    }

    $where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . $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 ($HTTP_GET_VARS['inc_subcat'] == '1') {
    $subcategories_array = array();
    tep_get_subcategories($subcategories_arr ay, $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 = '" . $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 = '" . $languages_id . "' and p2c.categories_id = '" . $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 = '" . $HTTP_GET_VARS['manufacturers_id'] . "'";
    }

    if (isset($HTTP_GET_VARS['keywords']) && tep_not_null($HTTP_GET_VARS['keywords'])) {
    if (tep_parse_search_string(stripslashes($H TTP_GET_VARS['keywords']), $search_keywords)) {
    $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:
    $where_str .= "(pd.products_name like '%" . addslashes($search_keywords[$i]) . "%' or p.products_model like '%" . addslashes($search_keywords[$i]) . "%' or m.manufacturers_name like '%" . addslashes($search_keywords[$i]) . "%'";
    if (isset($HTTP_GET_VARS['search_in_description']) && ($HTTP_GET_VARS['search_in_description'] == '1')) $where_str .= " or pd.products_description like '%" . addslashes($search_keywords[$i]) . "%'";
    $where_str .= ')';
    break;
    }
    }
    $where_str .= " )";
    }
    }

  12. #12
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    done

    if (isset($HTTP_GET_VARS['dfrom']) && tep_not_null($HTTP_GET_VARS['dfrom']) && ($HTTP_GET_VARS['dfrom'] != DOB_FORMAT_STRING)) {
    $where_str .= " and p.products_date_added >= '" . tep_date_raw($dfrom_to_check) . "'";
    }

    if (isset($HTTP_GET_VARS['dto']) && tep_not_null($HTTP_GET_VARS['dto']) && ($HTTP_GET_VARS['dto'] != DOB_FORMAT_STRING)) {
    $where_str .= " and p.products_date_added <= '" . tep_date_raw($dto_to_check) . "'";
    }

    $rate = $currencies->get_value($currency);
    if ($rate) {
    $pfrom = $HTTP_GET_VARS['pfrom'] / $rate;
    $pto = $HTTP_GET_VARS['pto'] / $rate;
    }

    if (DISPLAY_PRICE_WITH_TAX == 'true') {
    if ($pfrom) $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) ) >= " . $pfrom . ")";
    if ($pto) $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) ) <= " . $pto . ")";
    } else {
    if ($pfrom) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) >= " . $pfrom . ")";
    if ($pto) $where_str .= " and (IF(s.status, s.specials_new_products_price, p.products_price) <= " . $pto . ")";
    }

    if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ((isset($HTTP_GET_VARS['pfrom']) && tep_not_null($HTTP_GET_VARS['pfrom'])) || (isset($HTTP_GET_VARS['pto']) && tep_not_null($HTTP_GET_VARS['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 ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
    if ($column_list[$col] == 'PRODUCT_LIST_NAME') {
    $HTTP_GET_VARS['sort'] = $col+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', 'x', 'y')), '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');
    ?>

  13. #13
    Rogue Developer
    Join Date
    Oct 2002
    Posts
    191
    Can you tell us which field would have the data FORD GT? And which one has the numberplate information?

  14. #14
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74

    re

    sorry about the long delay...

    just to clear up, we don't sell ford gts, only numberplates. FORD GT was an example of a numberplate.

    the whole search thing is confusing the hell out of me, so i have devised an easy way, which should do for now, that is if anyone can helpme.

    if you go to my site, www.no-1-plates.com and type in c16 aaa, the product will come up, but not if you type in c16aaa. BUT if you type in c16 and aaa (with spaces inbetween the and as shown), you will get the numberplate c16 aaa.

    so what i need, is before the words c16aaa (or whatever someone types in) get send to the algorythm file, ie the one above, i need the computer to automatically place ' and ' (without the commers and with the spaces either side of the and), inbetween the letters in the keyword, allways 3 letters from the end, as numberplates allways have a gap, then 3 letters.

    what code shall i use for this? (i don't want the and to show up in the box as people will get confused)
    Last edited by davidstummer; 06-15-2003 at 01:49 PM.

  15. #15
    Loyal Client
    Join Date
    Mar 2003
    Posts
    74
    the following is the file that is used for the search box (where people type in):

    <?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
    */
    ?>
    <!-- search //-->
    <tr>
    <td>
    <?php
    $info_box_contents = array();
    $info_box_contents[] = array('text' => BOX_HEADING_SEARCH);

    new SearchBoxHeading($info_box_contents, false, false);

    $info_box_contents = array();
    $info_box_contents[] = array('form' => tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_R ESULT, '', 'NONSSL', false), 'get'),
    'align' => 'center',
    'text' => tep_draw_input_field('keywords', '', 'size="10" maxlength="30" style="width: ' . (BOX_WIDTH-30) . 'px"') . '&nbsp;' . tep_hide_session_id() . tep_image_submit('button_quick_find.gif' , BOX_HEADING_SEARCH) . '<br>' . BOX_SEARCH_TEXT . '<br><a href="' . tep_href_link(FILENAME_ADVANCED_SEARCH) . '"><b>' . BOX_SEARCH_ADVANCED_SEARCH . '</b></a>');

    new SearchBox($info_box_contents);
    ?>
    </td>
    </tr>
    <!-- search_eof //-->

Page 1 of 2 1 2 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •