how to have ranking based on how many words match user input
<p>In my query, I am basically trying to use fulltext searching for this search engine. When a user types in an item, the query looks to see if any fields are identical in my mysql table.</p>

<p>For example, say a user types in 'iPad'
. My table may have the fields 'title', 'description', 'keywords' and 'link':</p>

<p>My table may have:  </p>

<pre><code> Apple, which contains the term iPad once in the description
 iOS 6, which contains iPad say twice, in the description and title (these are examples)
 and iPad, which contains the term 'iPad' in the link, description, title and keywords.
</code></pre>

<p>The third result show be ranked first, followed by rank 2 and then id 1. </p>

<p>But say i want to type in 'buy iPad', the query does the exact same but checks for both words together. If no title/description/link/keywords can't find them two words together in a field, then it finds the first word's highest rank using the method i showed above. </p>

<pre><code>   Apple Store -&gt; which contains the terms Buy and iPad in the title field
</code></pre>

<p>If no matches are found, just determine the rank of each individual word and rank them by that.</p>

<pre><code>$query = " SELECT * FROM scan WHERE "; 

$terms = array_map('mysql_real_escape_string', $terms);
$i = 0; 
foreach ($terms as $each) {
      if ($i++ !== 0){
            $query .= " AND "; 
      }
      $query .= "Match(title, description, keywords, link) Against ('".implode(' ',$terms)." IN BOOLEAN MODE') ";
}
</code></pre>
