1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how come my search is not working

Discussion in 'HTML & Website Design' started by web-rover, Apr 21, 2005.

  1. #1
    Just noticed my search for my directory is not working.

    any thoughts Pet directory
     
    web-rover, Apr 21, 2005 IP
  2. serenity

    serenity Well-Known Member

    Messages:
    286
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Maybe you need to include the full path to the search.php

    Just a thought
     
    serenity, Apr 21, 2005 IP
  3. web-rover

    web-rover Peon

    Messages:
    1,341
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't think it is the search php....but here is the code.

    <?
    require_once("config.php");
    require_once("include.php");
    require_once("template_search.php");
    $replace = array("[SEARCH_TERM]" => convert($q));
    echo strtr($TEMPLATE["HEADING"],$replace);
    flush();
    $query = convert($q);
    if ($query){
    $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
    mysql_select_db($mysql_database, $bd);
    $array_query = split(" ",$query);
    $stop_words = array ("a","by","from","of","on","to","an","for","in","the","with","and","not","or","same");
    function non_stop_words($var){
    global $stop_words;
    return !in_array($var,$stop_words);
    };
    $array_query = array_filter($array_query, "non_stop_words");
    rsort($array_query);
    $sentence = "SELECT {$prefix}pages.id, {$prefix}pages.url, {$prefix}pages.title, {$prefix}pages.description, {$prefix}pages.keywords, {$prefix}pages.accepted, {$prefix}pages.ip, {$prefix}pages.category, {$prefix}categories.name AS category_name FROM {$prefix}pages, {$prefix}categories WHERE {$prefix}categories.id = {$prefix}pages.category";
    for ($x = 0; $x < min(4,count($array_query)); $x++){
    if ($x == 0){ $sentence .= " AND (";};
    $sentence .= " {$prefix}pages.title LIKE '%{$array_query[$x]}%' OR {$prefix}pages.keywords LIKE '%{$array_query[$x]}%' OR {$prefix}pages.description LIKE '%{$array_query[$x]}%' OR {$prefix}pages.url LIKE '%{$array_query[$x]}%'";
    if ($x != min(4,count($array_query))-1){
    $sentence .= " OR ";
    }else{
    $sentence .= ")";
    };
    };
    $sql = mysql_query($sentence);
    $n_results = mysql_num_rows($sql);
    if ($n_results > 0){
    $query2 = implode(" ",$array_query);
    for ($x = 0; $x < $n_results; $x++){
    $results[$x] = mysql_fetch_array($sql, MYSQL_ASSOC);
    $results[$x]["score"] = match(convert($results[$x]["title"]),$query2,40) + match(convert($results[$x]["keywords"]),$query2,30) + match(convert($results[$x]["description"]),$query2,20) + match(convert($results[$x]["url"]),$query2,10);
    if ($results[$x]["score"] > 0){
    $n_pages += 1;
    $pages[$n_pages-1] = $results[$x];
    };
    };
    if ($n_pages > 1){
    usort($pages,"sort_results");
    };
    };
    mysql_close();
    if ($show_additional_results){
    flush();
    require_once("include_ppc.php");
    $ppc_results = ppc_results(ucwords(convert($q)));
    $total_pages += count($ppc_results);
    for ($x = 1; $x <= count($ppc_results); $x++){
    $n_pages += 1;
    $pages[$n_pages-1] = $ppc_results[$x];
    };
    $e = min($s + $n - 1, (int) $n_pages);
    };
    };
    if ($s == 0) $s = 1;
    $n = 10;
    $e = min($s + $n - 1, (int) $n_pages);
    if ($n_pages > 0){
    $replace = array("[STARTING_PAGE_NUMBER]" => $s, "[ENDING_PAGE_NUMBER]" => $e, "[TOTAL_PAGES]" => $n_pages, "[SEARCH_TERM]" => convert($q));
    echo strtr($TEMPLATE["PAGES"]["HEADING"],$replace);
    for ($x = $s-1; $x < $e; $x++){
    if ($pages[$x]["category"] > 1){
    $category_url = $dir.'index.php?c='.$pages[$x]["category"];
    }else{
    $category_url = $dir;
    };
    if ($pages[$x]["domain"]){
    $replace = array("[PAGE_NUMBER]" => $x, "[PAGE_TITLE]" => $pages[$x]["title"], "[PAGE_DESCRIPTION]" => $pages[$x]["description"], "[PAGE_URL]" => $pages[$x]["url"], "[PAGE_DOMAIN]" => $pages[$x]["domain"], "[CATEGORY_NAME]" => $pages[$x]["category_name"], "[CATEGORY_URL]" => $category_url);
    echo strtr($TEMPLATE["PAGES"]["FEED_PAGE"],$replace);
    }else{
    $replace = array("[PAGE_NUMBER]" => $x, "[PAGE_TITLE]" => $pages[$x]["title"], "[PAGE_DESCRIPTION]" => $pages[$x]["description"], "[PAGE_URL]" => $pages[$x]["url"], "[CATEGORY_NAME]" => $pages[$x]["category_name"], "[CATEGORY_URL]" => $category_url);
    echo strtr($TEMPLATE["PAGES"]["PAGE"],$replace);
    };
    };
    if ($s != 1 || $e != $n_pages){
    function pagination($s){
    global $q, $dir;
    $query = $dir.'search.php?q='.urlencode(convert($q));
    if ($s > 1) $query .= '&s='.$s;
    return $query;
    };
    echo $TEMPLATE["PAGES"]["PAGINATION"]["HEADING"];
    if ($s != 1){
    $previous = $s - $n;
    $replace = array("[PAGINATION_URL]" => pagination($previous));
    echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["PREVIOUS"],$replace);
    };
    for ($x = 1; $x <= ceil($n_pages/$n); $x++){
    $current = ($x-1) * $n + 1;
    if ($current == $s){
    $replace = array("[PAGINATION_NUMBER]" => $x);
    echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["CURRENT_NUMBER"],$replace);
    }else{
    $replace = array("[PAGINATION_NUMBER]" => $x, "[PAGINATION_URL]" => pagination($current));
    echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["NUMBER"],$replace);
    };
    };
    if ($e < $n_pages){
    $next = $s + $n;
    $replace = array("[PAGINATION_URL]" => pagination($next));
    echo strtr($TEMPLATE["PAGES"]["PAGINATION"]["NEXT"],$replace);
    };
    echo $TEMPLATE["PAGES"]["PAGINATION"]["FOOTER"];
    };
    echo $TEMPLATE["PAGES"]["FOOTER"];
    }else{
    $replace = array("[SEARCH_TERM]" => convert($q));
    echo strtr($TEMPLATE["PAGES"]["NO_PAGES"],$replace);
    };
    echo $TEMPLATE["FOOTER"];
    ?>
     
    web-rover, Apr 23, 2005 IP
  4. web-rover

    web-rover Peon

    Messages:
    1,341
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i still haven't figured it out.

    any help would be great.
     
    web-rover, Apr 25, 2005 IP
  5. web-rover

    web-rover Peon

    Messages:
    1,341
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ok, the search works in firefox, but IE.

    very strange.
     
    web-rover, Apr 25, 2005 IP