簡體   English   中英

PHP搜索腳本增強

[英]PHP Search Script Enhancement

我有一個具有內置搜索功能的網站。 它允許用戶從主頁標題中搜索關鍵字。 用戶搜索任何關鍵字時,結果始終為:

沒有與您的查詢匹配的結果。

為了找到任何項目,用戶必須轉到高級搜索選項,然后在搜索框中輸入關鍵字,選中“搜索項目標題和描述”復選框,然后從“列出於”的下拉框中選擇“兩者” ”。

我不知道如何自動設置主頁搜索框來搜索每個選項。

下面是我用於搜索功能的代碼。 任何幫助將不勝感激:

<?php

session_start();

define ('IN_SITE', 1);

include_once ('includes/global.php');
include_once ('includes/class_formchecker.php');
include_once ('includes/class_custom_field.php');

include_once ('global_header.php');

$option = $db->rem_special_chars($_REQUEST['option']);
$option = (empty($option)) ? 'auction_search' : $option;
$template->set('option', $option);
$item_details = $db->rem_special_chars_array($_POST);
$template->set('item_details', $item_details);
$header_search_page = header5(GMSG_ADVANCED_SEARCH);
$template->set('header_search_page', $header_search_page);
if ($_REQUEST['search_empty'] == 1)
{
    $template->set('no_results_message', '<p align="center" class="errormessage">' . MSG_NO_RESULTS_QUERY . '</p>');
}
(string) $search_options_menu = null;
$search_options_menu .= display_link(process_link('search', array('option' => 'auction_search')), MSG_AUCTION_SEARCH, (($option = 'auction_search') ? false : true)) . ' | ';
$search_options_menu .= display_link(process_link('search', array('option' => 'seller_search')), MSG_SELLER_SEARCH, (($option = 'seller_search') ? false : true)) . ' | ';
$search_options_menu .= display_link(process_link('search', array('option' => 'buyer_search')), MSG_BUYER_SEARCH, (($option = 'buyer_search') ? false : true));
if ($setts['enable_stores']) 

$template->set('search_options_menu', $search_options_menu);
switch ($option)
{
    case 'auction_search':
        $search_options_title = MSG_AUCTION_SEARCH;
        $custom_fld = new custom_field();
        $custom_fld->new_table = false;
        $custom_fld->field_colspan = 2;
        $custom_fld->box_search = 1;
        $custom_sections_table = $custom_fld->display_sections($item_details, 'auction', false, 1, 0);
        $template->set('custom_sections_table', $custom_sections_table);
        $tax = new tax();       
        $template->set('country_dropdown', $tax->countries_dropdown('country', $item_details['country'], null, '', true));
        //$template->set('state_box', $tax->states_box('state', $item_details['state'], $item_details['country']));
        break;
    case 'seller_search':
        $search_options_title = MSG_SELLER_SEARCH;
        break;
    case 'buyer_search':
        $search_options_title = MSG_BUYER_SEARCH;
        break;
    case 'store_search':
        $search_options_title = MSG_STORE_SEARCH;
        break;
}
$template->set('search_options_title', $search_options_title);
$template_output .= $template->process('search.tpl.php');
include_once ('global_footer.php');
echo $template_output;
?>

經過研究后的這個問題是MySQL標准設置的結果。 最小搜索長度必須超過3個字符。 3個字符或更少的搜索長度不會產生搜索結果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM