Women in Technology

Hear us Roar

  Building a Simple Search Engine with PHP
Subject:   RE: multiple keywords EDIT
Date:   2004-09-21 11:10:36
From:   cityslicker
Response to: RE: multiple keywords

Hi again,

Just a small edit from the code above.

If a user seached for "good web sites" and a page contained 100's of 'good' but no 'web' and 'sites' then it would rank higher than a page which can have all three. This is not what we want so ammend the above code with this part:

for( $i = 1; $row = mysql_fetch_array($result); $i++ )

$score[$row['title']] += $row['occurrences']; //Array of scores
if($row['occurences'] > 0) { $score[$row['title']] += 1000; } //This makes pages containing all keywords rank highest

You can set the 1000 to whatever you like but you should be safe with that number.

Full Threads Newest First

Showing messages 1 through 2 of 2.

  • RE: multiple keywords EDIT
    2004-09-21 11:19:15  cityslicker [View]

    Hi once more!!

    Make sure you spell occurrences correctly unlike in my code above!!

    • RE: multiple keywords EDIT
      2009-11-04 09:45:30  xoqqa [View]

      Would you be so kind to send me your version of this search engine please? I've been trying to figure out what is wrong with mine and noticed that yours is somewhat different. For example I don't have page_title but just urls... I think you've also modified the populate script.

      I would appreciate if you can send me the script files on sammutmatu[at]gmail.com