예제 #1
0
function search_results($search_field)
{
    global $db;
    if (!$search_field) {
        return '';
    }
    $sql = "select doc_url, doc_title, \r\n\t\tMATCH (doc_title, doc_text) AGAINST ('" . $search_field . "') as score \r\n\t\tfrom " . DB_PREFIX . "zh_search\r\n\t\twhere MATCH (doc_title, doc_text) AGAINST ('" . $search_field . "')";
    $results = $db->Execute($sql);
    if ($results->RecordCount() == 0) {
        return TEXT_NO_RESULTS;
    }
    $search_array = array();
    $index = 0;
    while (!$results->EOF) {
        $score = number_format($index->fields['score'], 2);
        $search_array[$index]['doc_url'] = $results->fields['doc_url'];
        $search_array[$index]['doc_title'] = $results->fields['doc_title'];
        $index++;
        $results->MoveNext();
    }
    $search_string = build_href($search_array, $ref = '');
    return $search_string;
}
예제 #2
0
function search_results($search_text)
{
    global $db;
    if (!$search_text) {
        return '';
    }
    $sql = "select id, doc_url, doc_title, MATCH (doc_title, doc_text) AGAINST ('" . $search_text . "') as score \n    from " . TABLE_PHREEHELP . " where MATCH (doc_title, doc_text) AGAINST ('" . $search_text . "')";
    $results = $db->Execute($sql);
    if ($results->RecordCount() == 0) {
        return TEXT_NO_RESULTS;
    }
    $search_array = array();
    $index = 0;
    while (!$results->EOF) {
        $score = number_format($index->fields['score'], 2);
        $search_array[$index]['id'] = $results->fields['id'];
        $search_array[$index]['doc_url'] = $results->fields['doc_url'];
        $search_array[$index]['doc_title'] = $results->fields['doc_title'];
        $index++;
        $results->MoveNext();
    }
    $search_string = build_href($search_array, $ref = 'srch');
    return $search_string;
}