Women in Technology

Hear us Roar

  Building a Simple Search Engine with PHP
Subject:   Giving Back
Date:   2007-01-23 16:52:24
From:   PHPchick
I found this really helpful in getting up & running fast and wanted to give back as a "thanks". So here's a little bit that I added in my version:

/* create an array of words you want to exclude */
$filterWords = array('a', 'about', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'from', 'how', 'i', 'in', 'is', 'it', 'nbsp', 'of', 'on', 'or', 'that', 'the', 'this', 'to', 'was', 'we', 'what', 'when', 'where', 'which', 'with');

... later in the code ...

/* Does the current word already have a record in the word-table? */
$cur_word = addslashes( strtolower($words[$i][$j]) );

/* add the following to filter unwanted words */
if (!in_array( $cur_word, $filterWords)) {
... database selects/inserts...

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Giving Back
    2007-03-05 03:59:33  katie_P [View]

    Hi sorry to bother you, but do you know how to search for more than 1 word. There was code provided earlier on in this thread but it does'nt work for me

    $result = mysql_query(" SELECT p.page_url AS url,
    COUNT(*) AS occurrences
    FROM page p, word w1, occurrence o1, word w2, occurrence o2
    WHERE p.page_id = o1.page_id AND
    w1.word_id = o1.word_id AND
    w1.word_word = \"$keyword[1]\" AND
    w2.word_id = o2.word_id AND
    w2.word_word = \"$keyword[2]\" AND
    GROUP BY p.page_id
    ORDER BY occurrences DESC
    LIMIT $results" );

    I think you need to change an SQL statment, could you please help me

  • Giving Back
    2007-02-28 14:51:59  katie_P [View]

    Hiya im kind new to php stuff. Im I write in saying that you have to insert these code into the search document?