title: php searching multiple fields on msql and return exactly answer
body: <p>my be i may change the question explanation since no any help,But I real want help.
  I have a search box in my form which enable user to search student data in mysql table, I only succeed on searching single field eg (first name or second name or sir name) the BIG problem to me is how to search multiple field on  the same text input field or any number of text input field eg(text1, text2, text3) only I want is to have exactly result. Sorry if any mistake.</p>
  
  <p>Here the php codes I use to get single field search.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;&lt;input type="text" name="query" value=""/&gt;
       &lt;input name="submit" type="submit" value="Search" /&gt;
  
       &lt;?php
       $query="query";
  
  //mysql_connect
  
  $query='query';
  if (isset($_GET['query'])) 
      {    
          $query=$_GET['query'];
  
          // Instructions if $_POST['value'] exist    
      } 
  
  $raw_results = mysql_query("SELECT * FROM stdreg_exam 
                    WHERE (`fname` LIKE '%".$query."%') or (`secname` LIKE '%".$query."%')or  
                       (`date` LIKE '%".$query."%') or (`surname` LIKE '%".$query."%')") or  
      die(mysql_error());
  
  
  $raw_results2 = mysql_query("SELECT(idnumber) FROM student 
                             WHERE (`fname` LIKE '%".$query."%') or (`secname` LIKE  
                              '%".$query."%') or (`date` LIKE '%".$query."%')or    
                                (`surname` LIKE '%".$query."%')") or die(mysql_error());  
  
  
  // * means that it selects all fields, you can also write: `id`, `title`, `text`
  // articles is the name of our table
  
  // '%$query%' is what we're looking for, % means anything, for example if $query is Hello
  // it will match "hello", "Hello man", "gogohello", if you want exact match use `title`='$query'
  // or if you want to match just full word so "gogohello" is out use '% $query %' ...OR ... '$query %' ... OR ... '% $query'
  
  if(mysql_num_rows($raw_results) &gt; 0){ 
      // if one or more rows are  
      returned do following
  
  
                      while($results = mysql_fetch_array($raw_results)){
                          while($results2 = mysql_fetch_array($raw_results2)){
  
                              // $results = mysql_fetch_array($raw_results) puts data from database into  
                              array, while it's valid it does the loop
  
      echo "&lt;table width='750' height='5' cellpadding='2'  
                                           cellspacing='0' border='0'&gt;";
  echo"&lt;tr&gt;&lt;td&gt;Std_id&lt;/td&gt;&lt;td&gt;Mathematics&lt;/td&gt;&lt;td&gt;English&lt;/td&gt; 
                 &lt;td&gt;Kiswahili&lt;/td&gt;&lt;td&gt;Geograph&lt;/td&gt;&lt;td&gt;Ict&lt;/td&gt;&lt;td&gt;Science&lt;/td&gt; 
                  &lt;td&gt;History&lt;/td&gt;&lt;td&gt;Pds&lt;/td&gt;&lt;td&gt;V skill&lt;/td&gt;&lt;td&gt;French&lt;/td&gt; 
                   &lt;td&gt;Religion&lt;/td&gt;&lt;td&gt;Civics&lt;/td&gt;";
  echo "&lt;h4&gt;&amp;nbsp;".$results['exam_name']."&amp;nbsp; Examination result for   
                    &amp;nbsp;" .$results['fname']."&amp;nbsp;" .$results['secname']  
  ."&amp;nbsp;".$results['surname']."&amp;nbsp;".$results['class']."&amp;nbsp;Class"."&amp;nbsp;        
                        held on&lt;/p&gt;".$results['date']."&lt;hr&gt;&lt;th&gt;"; echo"&lt;tr&gt;";
  
  echo ""."&lt;td&gt;".$results2['idnumber'].""."&lt;td&gt;".$results['mathematics']."%"." 
                 &lt;td&gt;".$results['english']."%"."&lt;td&gt;".$results['kiswahili']."%"."  
                 &lt;td&gt;".$results['geograph']."%"."&lt;td&gt;".$results['ict']."%"."
                 &lt;td&gt;".$results['science']."%"."&lt;td&gt;".$results['history']."%"." 
                 &lt;td&gt;".$results['pds']."%"."&lt;td&gt;".$results['vskill']."%"." 
                 &lt;td&gt;".$results['french']."%"."&lt;td&gt;".$results['religion']."%"." 
                 &lt;td&gt;".$results['civics']."%"."&lt;/td&gt;&lt;/p&gt;";echo"&lt;/table&gt;";                
  //posts results gotten from database(title and text) you can also show id  
  ($results['id'])
  }
  
  }
  }
                 else{ 
                     // if there is no matching rows do following
                     echo "No such information in School database";
                 }
  
  }
                       else{ 
                           // if query length is less than minimum
                           echo "Enter more strings!!!Minimum length is ".$min_length; "Charactes";
                       }
  
  ?&gt;
  </code></pre>