title: Searching Database in PHP From single column to all
body: <p>Ok, I am new to this but this is what I need. I have a code that will search a specific column and return what I search for, but how do I fix this code to search for anything in my database and display the corresponding row information.</p>
  
  <pre><code>&lt;?php
  //PHP CODE STARTS HERE
  
  if(isset($_GET['submit'])){
  
      // Change the fields below as per the requirements
      $db_host="localhost";
      $db_username="megan";
      $db_password="megan";
      $db_name="megan";
      $db_tb_name="user";
      $db_tb_atr_name="location";
  
      mysql_connect("$db_host","$db_username","$db_password");
      mysql_select_db("$db_name");
  
      $query=mysql_real_escape_string($_GET['query']);
  
      $query_for_result=mysql_query("SELECT * FROM $db_tb_name WHERE 
      $db_tb_atr_name like '%".$query."%'");
  
  
      echo "&lt;h2&gt;Search Results&lt;/h2&gt;&lt;ol&gt;";
      while ($data_fetch=mysql_fetch_array($query_for_result))
      {
          echo "&lt;li&gt;";
          echo substr($data_fetch[$db_tb_atr_name], 0,160);
          echo "&lt;/li&gt;&lt;hr/&gt;";
      }
      echo "&lt;/ol&gt;";
  
      mysql_close();
  }
  ?&gt;
  </code></pre>
  
  <p>This is what I have. As you can see it currently searches the location column for the information. But I want to be able to search any word, in any column. Currently, it will show the number of occurring that keyword shows up but not the rest of the row information. I hope this makes sense.</p>