title: MYSQL fulltext search order by relevance
body: <p>I am trying to get my Full text search to order by relevance. here is my code it works if remove the ORDER BY but doesn't sort by relevance. I have tried this and it actually makes it so it doesnt find any results at all... Any ideas?</p>
  
  <pre><code>$query_for_result=mysql_query("
       SELECT * FROM Assets WHERE MATCH 
      (`Badge`,`First Name`,`Last Name`,`Service Tag`,`Asset Tag`)
       AGAINST ('".$query."*' IN BOOLEAN MODE) and
     `deleted` = '0'  ORDER BY relevance DESC");
  </code></pre>
  
  <p>edit*
      </p>
  
  <pre><code>&lt;input type="text" name="query" /&gt;
  &lt;input type="hidden" value="Search" name="submit" /&gt;
  &lt;input type="submit" name="submit" value="Search" /&gt;
  
  &lt;/form&gt;
  &lt;h4&gt;Search by: Badge, First or Last Name, Service Tag, Asset Tag, Printer Queue or Printer IP.&lt;/h4&gt;
  &lt;br&gt;
  &lt;/center&gt;
  
  &lt;?php
  
  
  if(isset($_GET['submit'])){
  
  
  $db_tb_name=Assets;
  $db_tb_atr_name=`First Name`;
  
  $query=mysql_real_escape_string($_GET['query']);
  
  $query_for_result=mysql_query("
   SELECT * FROM Assets WHERE MATCH 
  (`Badge`,`First Name`,`Last Name`,`Service Tag`,`Asset Tag`)
   AGAINST ('".$query."*' IN BOOLEAN MODE) and
  `deleted` = '0'  ORDER BY relevance DESC");
  </code></pre>
  
  <p>then later on in the code</p>
  
  <pre><code>while($data_fetch=mysql_fetch_array($query_for_result))
  {
  
  print '&lt;h3&gt;';   
  print "&lt;a href=\"modify.php?id=" . $data_fetch['id'] . "\"&gt;" . $data_fetch['First Name']  . ' ' . $data_fetch['Last Name'] . "&lt;/a&gt;";
  print '&lt;br/&gt;&lt;b&gt;Badge:&lt;/b&gt; '. $data_fetch['Badge'];
  print '&lt;br/&gt; &lt;b&gt;Service Tag:&lt;/b&gt; '. $data_fetch['Service Tag'];
  print ' &lt;b&gt;Asset Tag:&lt;/b&gt; '. $data_fetch['Asset Tag'];
  print '&lt;br/&gt; &lt;b&gt;Status:&lt;/b&gt; '. $data_fetch['Status'];
  print '&lt;br/&gt;&lt;b&gt;Employee Status: &lt;/b&gt;';
      if( $data_fetch['Employee Status'] == 'Active' ){
  print '&lt;font color="#32CD32"&gt;' . $data_fetch['Employee Status'] . '&lt;/font&gt;';
      }
  elseif( $data_fetch['Employee Status'] == 'Terminated' ){
  print '&lt;font color="red"&gt;' . $data_fetch['Employee Status'] . '&lt;/font&gt;';}
  print '&lt;br/&gt; &lt;b&gt;Last Modified:&lt;/b&gt; '. $data_fetch['Last Modified'];
  print "&lt;span&gt; &lt;/span&gt;";
  print '&lt;/h3&gt;';
  print '&lt;br/&gt;&lt;p&gt;' ; 
  
  }
  </code></pre>
  
  <p><em>UPDATE</em>
  This worked for me
  I finally got it working by using</p>
  
  <pre><code>$query_for_result=mysql_query("SELECT  *, MATCH 
  (`Badge`,`First Name`,`Last     Name`,`Service Tag`,`Asset Tag`) 
  AGAINST ('".$query."'IN BOOLEAN MODE) AS Relevance FROM Assets WHERE 1 AND MATCH 
  (`Badge`,`First Name`,`Last Name`,`Service Tag`,`Asset Tag`)
  AGAINST ('".$query."' IN BOOLEAN MODE) and
   `deleted` = '0' ORDER BY Relevance DESC "); 
  </code></pre>