ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  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.



1 to 1 of 1
  1. RE: multiple keywords EDIT
    2004-09-21 11:19:15  cityslicker [View]

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

1 to 1 of 1