How can I scan all my fields in MySQL for form input
<p>In my script below, the user inputs a form and rows are returned from a MYSQL table if rows are similar to inputted by the user. I am building a search engine and everything is based on rank. But I want to be able to adjust the code below to see how many times the word 'iPad' for example comes up with the row fields, which are 'title', 'description', 'keywords' and 'link'. If so, I want that row to return higher than say a row that has a higher id, but only mentions iPad once in all of the fields combined.
My code is below: 
            Terms together query:
            $query = " SELECT * FROM scan WHERE "; </p>

<pre><code>$terms = array_map('mysql_real_escape_string', $terms);
$i = 0; 
foreach ($terms as $each) {
      if ($i++ !== 0){
            $query .= " AND "; 
      }
      $query .= "title LIKE '%{$each}%' OR link LIKE '%{$each}%' OR  keywords LIKE '%{$each}%' OR description LIKE '%{$each}%' ";

}

   $query = mysql_query($query) or die('MySQL Query Error: ' . mysql_error( $connect ));

echo '&lt;p class="time"&gt;Qlick showed your results in ' . number_format($secs,2) . ' seconds.&lt;/p&gt;';     

 $numrows = mysql_num_rows($query);
if ($numrows &gt; 0) {

      while ($row = mysql_fetch_assoc($query)) {
            $id = $row['id'];
            $title = $row['title'];
            $description = $row['description'];
            $keywords = $row['keywords'];
            $link = $row['link'];
            $rank = $row['rank'];


   Seperate Terms Query

            $query = " SELECT * FROM scan WHERE "; 

    $terms = array_map('mysql_real_escape_string', $terms);
    $i = 0; 
    foreach ($terms as $each) {
          if ($i++ !== 0){
                $query .= " OR "; 
          }
          $query .= "title LIKE '%{$each}%' OR link LIKE '%{$each}%' OR  keywords LIKE '%{$each}%' OR description LIKE '%{$each}%' ";
      }

    // Don't append the ORDER BY until after the loop

          $query = mysql_query($query) or die('MySQL Query Error: ' . mysql_error( $connect ));
    $numrows = mysql_num_rows($query);
    if ($numrows &gt; 0) {

          while ($row = mysql_fetch_assoc($query)) {
                $id = $row['id'];
                $title = $row['title'];
                $description = $row['description'];
                $keywords = $row['keywords'];
                $link = $row['link'];
                $rank = $row['rank'];
</code></pre>
