title: PHP search with multiple fields
body: <p>I want to search data using ajax method with multiple fields search option (e.g. name, college, department, year, nationality e.t.c ). I have insert name for searching and rest of fields are empty than it went to foreach loop but this if (isset($_GET[$field]) &amp;&amp; !empty($_GET['$field'])) condition not successful and went to else loop</p>
  
  <pre><code>  $fields = array(
    'name' =&gt; TRUE,
    'gender' =&gt; TRUE,
    'colf' =&gt; TRUE,
    'deptf' =&gt; TRUE,
    'natf' =&gt; TRUE,
    'fstatusf' =&gt; TRUE,
    'fyearf' =&gt; TRUE
    );
   foreach ($fields as $field =&gt; $like) {
    if (isset($_GET[$field]) &amp;&amp; !empty($_GET['$field'])) {
      $value = $_GET[$field];
      $search[] = $field . ( $like ? ('LIKE "%' . $value . '%"') : ('="' . $value . '"') );
         }
   } 
    if ($search) {
    $sql = 'SELECT * FROM fmaf WHERE ' . implode(' or ' . $search);
    }
  
  else{
  $sql="SELECT * FROM fmaf";
  
      }
  </code></pre>